Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a.
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
|
||||
CustomMap::CustomMap()
|
||||
{
|
||||
m_NodePool = nullptr;
|
||||
m_NodePool = NULL;
|
||||
m_NodePoolSize = 0;
|
||||
m_NodePoolIndex = 0;
|
||||
|
||||
m_HashSize = 1024;
|
||||
m_HashTable = static_cast<SCustomMapNode **>(malloc(m_HashSize * sizeof(SCustomMapNode)));
|
||||
m_HashTable = (SCustomMapNode**) malloc(m_HashSize * sizeof(SCustomMapNode));
|
||||
|
||||
clear();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void CustomMap::insert(const ChunkPos &Key, bool Value)
|
||||
Node->Hash = Hash;
|
||||
Node->first = Key;
|
||||
Node->second = Value;
|
||||
Node->Next = nullptr;
|
||||
Node->Next = NULL;
|
||||
|
||||
// are any nodes in this hash index
|
||||
if( !m_HashTable[Index] )
|
||||
@@ -115,16 +115,16 @@ void CustomMap::resize()
|
||||
SCustomMapNode **NodePool;
|
||||
if( m_NodePool )
|
||||
{
|
||||
NodePool = static_cast<SCustomMapNode **>(realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomMapNode)));
|
||||
NodePool = (SCustomMapNode**) realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomMapNode));
|
||||
}
|
||||
else
|
||||
{
|
||||
NodePool = static_cast<SCustomMapNode **>(malloc(m_NodePoolSize * sizeof(SCustomMapNode)));
|
||||
NodePool = (SCustomMapNode**) malloc(m_NodePoolSize * sizeof(SCustomMapNode));
|
||||
}
|
||||
|
||||
for( int i = 0;i < m_NodePoolSize - OldPoolSize;i += 1 )
|
||||
{
|
||||
NodePool[i + OldPoolSize] = static_cast<SCustomMapNode *>(malloc(sizeof(SCustomMapNode)));
|
||||
NodePool[i + OldPoolSize] = (SCustomMapNode*) malloc(sizeof(SCustomMapNode));
|
||||
}
|
||||
|
||||
m_NodePool = NodePool;
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
CustomSet::CustomSet()
|
||||
{
|
||||
m_NodePool = nullptr;
|
||||
m_NodePool = NULL;
|
||||
m_NodePoolSize = 0;
|
||||
m_NodePoolIndex = 0;
|
||||
|
||||
m_HashSize = 1024;
|
||||
m_HashTable = static_cast<SCustomSetNode **>(malloc(m_HashSize * sizeof(SCustomSetNode)));
|
||||
m_HashTable = (SCustomSetNode**) malloc(m_HashSize * sizeof(SCustomSetNode));
|
||||
|
||||
clear();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void CustomSet::insert(const ChunkPos &Key)
|
||||
unsigned int Index = Hash & (m_HashSize-1);
|
||||
Node->Hash = Hash;
|
||||
Node->key = Key;
|
||||
Node->Next = nullptr;
|
||||
Node->Next = NULL;
|
||||
|
||||
// are any nodes in this hash index
|
||||
if( !m_HashTable[Index] )
|
||||
@@ -113,16 +113,16 @@ void CustomSet::resize()
|
||||
SCustomSetNode **NodePool;
|
||||
if( m_NodePool )
|
||||
{
|
||||
NodePool = static_cast<SCustomSetNode **>(realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomSetNode)));
|
||||
NodePool = (SCustomSetNode**) realloc(m_NodePool, m_NodePoolSize * sizeof(SCustomSetNode));
|
||||
}
|
||||
else
|
||||
{
|
||||
NodePool = static_cast<SCustomSetNode **>(malloc(m_NodePoolSize * sizeof(SCustomSetNode)));
|
||||
NodePool = (SCustomSetNode**) malloc(m_NodePoolSize * sizeof(SCustomSetNode));
|
||||
}
|
||||
|
||||
for( int i = 0;i < m_NodePoolSize - OldPoolSize;i += 1 )
|
||||
{
|
||||
NodePool[i + OldPoolSize] = static_cast<SCustomSetNode *>(malloc(sizeof(SCustomSetNode)));
|
||||
NodePool[i + OldPoolSize] = (SCustomSetNode*) malloc(sizeof(SCustomSetNode));
|
||||
}
|
||||
|
||||
m_NodePool = NodePool;
|
||||
|
||||
@@ -15,7 +15,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID)
|
||||
if( result != S_OK )
|
||||
{
|
||||
app.DebugPrintf("sceCesUcsContextInit failed\n");
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t utf16Len;
|
||||
@@ -44,7 +44,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID)
|
||||
if( result != SCE_OK )
|
||||
{
|
||||
app.DebugPrintf("sceCesUtf16StrToUtf8Str: conversion error : 0x%x\n", result);
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return strUtf8;
|
||||
|
||||
@@ -137,7 +137,7 @@ BOOL PSVitaTLSStorage::SetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
||||
#else
|
||||
|
||||
|
||||
PSVitaTLSStorage* m_pInstance = nullptr;
|
||||
PSVitaTLSStorage* m_pInstance = NULL;
|
||||
|
||||
#define sc_maxSlots 64
|
||||
BOOL m_activeList[sc_maxSlots];
|
||||
@@ -157,7 +157,7 @@ void PSVitaTLSStorage::Init()
|
||||
for(int i=0;i<sc_maxSlots; i++)
|
||||
{
|
||||
m_activeList[i] = false;
|
||||
// m_values[i] = nullptr;
|
||||
// m_values[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ DWORD PSVitaTLSStorage::Alloc()
|
||||
if(m_activeList[i] == false)
|
||||
{
|
||||
m_activeList[i] = true;
|
||||
// m_values[i] = nullptr;
|
||||
// m_values[i] = NULL;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ BOOL PSVitaTLSStorage::Free( DWORD _index )
|
||||
return false; // not been allocated
|
||||
|
||||
m_activeList[_index] = false;
|
||||
// m_values[_index] = nullptr;
|
||||
// m_values[_index] = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ BOOL PSVitaTLSStorage::SetValue( DWORD _index, LPVOID _val )
|
||||
LPVOID PSVitaTLSStorage::GetValue( DWORD _index )
|
||||
{
|
||||
if(m_activeList[_index] == false)
|
||||
return nullptr;
|
||||
return NULL;
|
||||
return user_getValue(_index);
|
||||
// return m_values[_index];
|
||||
}
|
||||
@@ -218,8 +218,8 @@ void PSVitaTLSStorage::RemoveThread(int threadID)
|
||||
{
|
||||
for(int i=0; i<sc_maxSlots; i++)
|
||||
{
|
||||
//m_values[i] = nullptr;
|
||||
user_setValue(i, nullptr);
|
||||
//m_values[i] = NULL;
|
||||
user_setValue(i, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ size_t wcsnlen(const wchar_t *wcs, size_t maxsize)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
// Note that we do not check if s == nullptr, because we do not
|
||||
// Note that we do not check if s == NULL, because we do not
|
||||
// return errno_t...
|
||||
|
||||
for (n = 0; n < maxsize && *wcs; n++, wcs++)
|
||||
@@ -162,7 +162,7 @@ VOID GetLocalTime(LPSYSTEMTIME lpSystemTime)
|
||||
lpSystemTime->wMilliseconds = sceRtcGetMicrosecond(&dateTime)/1000;
|
||||
}
|
||||
|
||||
HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { PSVITA_STUBBED; return nullptr; }
|
||||
HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) { PSVITA_STUBBED; return NULL; }
|
||||
VOID Sleep(DWORD dwMilliseconds)
|
||||
{
|
||||
C4JThread::Sleep(dwMilliseconds);
|
||||
@@ -186,7 +186,7 @@ VOID InitializeCriticalSection(PCRITICAL_SECTION CriticalSection)
|
||||
{
|
||||
char name[1] = {0};
|
||||
|
||||
int err = sceKernelCreateLwMutex((SceKernelLwMutexWork *)(&CriticalSection->mutex), name, SCE_KERNEL_LW_MUTEX_ATTR_TH_PRIO | SCE_KERNEL_LW_MUTEX_ATTR_RECURSIVE, 0, nullptr);
|
||||
int err = sceKernelCreateLwMutex((SceKernelLwMutexWork *)(&CriticalSection->mutex), name, SCE_KERNEL_LW_MUTEX_ATTR_TH_PRIO | SCE_KERNEL_LW_MUTEX_ATTR_RECURSIVE, 0, NULL);
|
||||
PSVITA_ASSERT_SCE_ERROR(err);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ extern CRITICAL_SECTION g_singleThreadCS;
|
||||
|
||||
VOID EnterCriticalSection(PCRITICAL_SECTION CriticalSection)
|
||||
{
|
||||
int err = sceKernelLockLwMutex ((SceKernelLwMutexWork *)(&CriticalSection->mutex), 1, nullptr);
|
||||
int err = sceKernelLockLwMutex ((SceKernelLwMutexWork *)(&CriticalSection->mutex), 1, NULL);
|
||||
PSVITA_ASSERT_SCE_ERROR(err);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ VOID InitializeCriticalRWSection(PCRITICAL_RW_SECTION CriticalSection)
|
||||
{
|
||||
char name[1] = {0};
|
||||
|
||||
CriticalSection->RWLock = sceKernelCreateRWLock(name, SCE_KERNEL_RW_LOCK_ATTR_TH_PRIO | SCE_KERNEL_RW_LOCK_ATTR_RECURSIVE, nullptr);
|
||||
CriticalSection->RWLock = sceKernelCreateRWLock(name, SCE_KERNEL_RW_LOCK_ATTR_TH_PRIO | SCE_KERNEL_RW_LOCK_ATTR_RECURSIVE, NULL);
|
||||
}
|
||||
|
||||
VOID DeleteCriticalRWSection(PCRITICAL_RW_SECTION CriticalSection)
|
||||
@@ -270,9 +270,11 @@ VOID LeaveCriticalRWSection(PCRITICAL_RW_SECTION CriticalSection, bool Write)
|
||||
PSVITA_ASSERT_SCE_ERROR(err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CloseHandle(HANDLE hObject)
|
||||
{
|
||||
sceFiosFHCloseSync(nullptr,(SceFiosFH)(reinterpret_cast<int32_t>(hObject)));
|
||||
sceFiosFHCloseSync(NULL,(SceFiosFH)((int32_t)hObject));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -512,7 +514,7 @@ BOOL VirtualWriteFile(LPCSTR lpFileName, LPCVOID lpBuffer, DWORD nNumberOfBytesT
|
||||
void* Data = VirtualAllocs[Page];
|
||||
|
||||
DWORD numberOfBytesWritten=0;
|
||||
WriteFileWithName(lpFileName, Data, BytesToWrite, &numberOfBytesWritten,nullptr);
|
||||
WriteFileWithName(lpFileName, Data, BytesToWrite, &numberOfBytesWritten,NULL);
|
||||
*lpNumberOfBytesWritten += numberOfBytesWritten;
|
||||
|
||||
nNumberOfBytesToWrite -= BytesToWrite;
|
||||
@@ -654,7 +656,7 @@ DWORD GetFileSize( HANDLE hFile, LPDWORD lpFileSizeHigh )
|
||||
//SceFiosSize FileSize;
|
||||
//FileSize=sceFiosFHGetSize(fh);
|
||||
SceFiosStat statData;
|
||||
int err = sceFiosFHStatSync(nullptr,fh,&statData);
|
||||
int err = sceFiosFHStatSync(NULL,fh,&statData);
|
||||
SceFiosOffset FileSize = statData.fileSize;
|
||||
|
||||
if(lpFileSizeHigh)
|
||||
@@ -673,7 +675,7 @@ BOOL WriteFileWithName(LPCSTR lpFileName, LPCVOID lpBuffer, DWORD nNumberOfByte
|
||||
{
|
||||
char filePath[256];
|
||||
sprintf(filePath,"%s/%s",getUsrDirPath(), lpFileName );
|
||||
SceFiosSize bytesWritten = sceFiosFileWriteSync( nullptr, filePath, lpBuffer, nNumberOfBytesToWrite, 0 );
|
||||
SceFiosSize bytesWritten = sceFiosFileWriteSync( NULL, filePath, lpBuffer, nNumberOfBytesToWrite, 0 );
|
||||
if(bytesWritten != nNumberOfBytesToWrite)
|
||||
{
|
||||
// error
|
||||
@@ -696,7 +698,7 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD
|
||||
{
|
||||
SceFiosFH fh = (SceFiosFH)((int64_t)hFile);
|
||||
// sceFiosFHReadSync - Non-negative values are the number of bytes read, 0 <= result <= length. Negative values are error codes.
|
||||
SceFiosSize bytesRead = sceFiosFHReadSync(nullptr, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead);
|
||||
SceFiosSize bytesRead = sceFiosFHReadSync(NULL, fh, lpBuffer, (SceFiosSize)nNumberOfBytesToRead);
|
||||
if(bytesRead < 0)
|
||||
{
|
||||
// error
|
||||
@@ -716,7 +718,7 @@ BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHi
|
||||
uint64_t bitsToMove = (int64_t) lDistanceToMove;
|
||||
SceFiosOffset pos = 0;
|
||||
|
||||
if (lpDistanceToMoveHigh != nullptr)
|
||||
if (lpDistanceToMoveHigh != NULL)
|
||||
bitsToMove |= ((uint64_t) (*lpDistanceToMoveHigh)) << 32;
|
||||
|
||||
SceFiosWhence whence = SCE_FIOS_SEEK_SET;
|
||||
@@ -759,7 +761,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
if( dwDesiredAccess == GENERIC_WRITE )
|
||||
{
|
||||
//CD - Create a blank file
|
||||
int err = sceFiosFileWriteSync( nullptr, filePath, nullptr, 0, 0 );
|
||||
int err = sceFiosFileWriteSync( NULL, filePath, NULL, 0, 0 );
|
||||
assert( err == SCE_FIOS_OK );
|
||||
}
|
||||
|
||||
@@ -768,7 +770,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
#endif
|
||||
|
||||
SceFiosFH fh;
|
||||
int err = sceFiosFHOpenSync(nullptr, &fh, filePath, nullptr);
|
||||
int err = sceFiosFHOpenSync(NULL, &fh, filePath, NULL);
|
||||
assert( err == SCE_FIOS_OK );
|
||||
|
||||
return (void*)fh;
|
||||
@@ -814,7 +816,7 @@ DWORD GetFileAttributesA(LPCSTR lpFileName)
|
||||
|
||||
// check if the file exists first
|
||||
SceFiosStat statData;
|
||||
if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK)
|
||||
if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK)
|
||||
{
|
||||
app.DebugPrintf("*** sceFiosStatSync Failed\n");
|
||||
return -1;
|
||||
@@ -902,7 +904,7 @@ BOOL GetFileAttributesExA(LPCSTR lpFileName,GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
||||
|
||||
// check if the file exists first
|
||||
SceFiosStat statData;
|
||||
if(sceFiosStatSync(nullptr, filePath, &statData) != SCE_FIOS_OK)
|
||||
if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK)
|
||||
{
|
||||
app.DebugPrintf("*** sceFiosStatSync Failed\n");
|
||||
return false;
|
||||
@@ -935,7 +937,7 @@ errno_t _i64toa_s(long long _Val, char * _DstBuf, size_t _Size, int _Radix) { if
|
||||
|
||||
int _wtoi(const wchar_t *_Str)
|
||||
{
|
||||
return wcstol(_Str, nullptr, 10);
|
||||
return wcstol(_Str, NULL, 10);
|
||||
}
|
||||
|
||||
DWORD XGetLanguage()
|
||||
|
||||
@@ -16,12 +16,12 @@ C4JThread::EventArray *ShutdownManager::s_eventArray[eThreadIdCount];
|
||||
void ShutdownManager::Initialise()
|
||||
{
|
||||
#ifdef __PS3__
|
||||
cellSysutilRegisterCallback( 1, SysUtilCallback, nullptr );
|
||||
cellSysutilRegisterCallback( 1, SysUtilCallback, NULL );
|
||||
for( int i = 0; i < eThreadIdCount; i++ )
|
||||
{
|
||||
s_threadShouldRun[i] = true;
|
||||
s_threadRunning[i] = 0;
|
||||
s_eventArray[i] = nullptr;
|
||||
s_eventArray[i] = NULL;
|
||||
}
|
||||
// Special case for storage manager, which we will manually set now to be considered as running - this will be unset by StorageManager.ExitRequest if required
|
||||
s_threadRunning[eStorageManagerThreads] = true;
|
||||
|
||||
@@ -210,7 +210,7 @@ LIBDIVIDE_API __m128i libdivide_s64_do_vector_alg4(__m128i numers, const struct
|
||||
static inline uint32_t libdivide__mullhi_u32(uint32_t x, uint32_t y) {
|
||||
uint64_t xl = x, yl = y;
|
||||
uint64_t rl = xl * yl;
|
||||
return static_cast<uint32_t>(rl >> 32);
|
||||
return (uint32_t)(rl >> 32);
|
||||
}
|
||||
|
||||
static uint64_t libdivide__mullhi_u64(uint64_t x, uint64_t y) {
|
||||
@@ -221,12 +221,12 @@ static uint64_t libdivide__mullhi_u64(uint64_t x, uint64_t y) {
|
||||
#else
|
||||
//full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64)
|
||||
const uint32_t mask = 0xFFFFFFFF;
|
||||
const uint32_t x0 = static_cast<uint32_t>(x & mask), x1 = static_cast<uint32_t>(x >> 32);
|
||||
const uint32_t y0 = static_cast<uint32_t>(y & mask), y1 = static_cast<uint32_t>(y >> 32);
|
||||
const uint32_t x0 = (uint32_t)(x & mask), x1 = (uint32_t)(x >> 32);
|
||||
const uint32_t y0 = (uint32_t)(y & mask), y1 = (uint32_t)(y >> 32);
|
||||
const uint32_t x0y0_hi = libdivide__mullhi_u32(x0, y0);
|
||||
const uint64_t x0y1 = x0 * static_cast<uint64_t>(y1);
|
||||
const uint64_t x1y0 = x1 * static_cast<uint64_t>(y0);
|
||||
const uint64_t x1y1 = x1 * static_cast<uint64_t>(y1);
|
||||
const uint64_t x0y1 = x0 * (uint64_t)y1;
|
||||
const uint64_t x1y0 = x1 * (uint64_t)y0;
|
||||
const uint64_t x1y1 = x1 * (uint64_t)y1;
|
||||
|
||||
uint64_t temp = x1y0 + x0y0_hi;
|
||||
uint64_t temp_lo = temp & mask, temp_hi = temp >> 32;
|
||||
@@ -242,12 +242,12 @@ static inline int64_t libdivide__mullhi_s64(int64_t x, int64_t y) {
|
||||
#else
|
||||
//full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64)
|
||||
const uint32_t mask = 0xFFFFFFFF;
|
||||
const uint32_t x0 = static_cast<uint32_t>(x & mask), y0 = static_cast<uint32_t>(y & mask);
|
||||
const int32_t x1 = static_cast<int32_t>(x >> 32), y1 = static_cast<int32_t>(y >> 32);
|
||||
const uint32_t x0 = (uint32_t)(x & mask), y0 = (uint32_t)(y & mask);
|
||||
const int32_t x1 = (int32_t)(x >> 32), y1 = (int32_t)(y >> 32);
|
||||
const uint32_t x0y0_hi = libdivide__mullhi_u32(x0, y0);
|
||||
const int64_t t = x1*static_cast<int64_t>(y0) + x0y0_hi;
|
||||
const int64_t w1 = x0*static_cast<int64_t>(y1) + (t & mask);
|
||||
return x1*static_cast<int64_t>(y1) + (t >> 32) + (w1 >> 32);
|
||||
const int64_t t = x1*(int64_t)y0 + x0y0_hi;
|
||||
const int64_t w1 = x0*(int64_t)y1 + (t & mask);
|
||||
return x1*(int64_t)y1 + (t >> 32) + (w1 >> 32);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ static inline int32_t libdivide__count_trailing_zeros64(uint64_t val) {
|
||||
/* Pretty good way to count trailing zeros. Note that this hangs for val = 0! */
|
||||
uint32_t lo = val & 0xFFFFFFFF;
|
||||
if (lo != 0) return libdivide__count_trailing_zeros32(lo);
|
||||
return 32 + libdivide__count_trailing_zeros32(static_cast<uint32_t>(val >> 32));
|
||||
return 32 + libdivide__count_trailing_zeros32((uint32_t)(val >> 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -444,9 +444,9 @@ static uint32_t libdivide_64_div_32_to_32(uint32_t u1, uint32_t u0, uint32_t v,
|
||||
}
|
||||
#else
|
||||
static uint32_t libdivide_64_div_32_to_32(uint32_t u1, uint32_t u0, uint32_t v, uint32_t *r) {
|
||||
uint64_t n = (static_cast<uint64_t>(u1) << 32) | u0;
|
||||
uint32_t result = static_cast<uint32_t>(n / v);
|
||||
*r = static_cast<uint32_t>(n - result * static_cast<uint64_t>(v));
|
||||
uint64_t n = (((uint64_t)u1) << 32) | u0;
|
||||
uint32_t result = (uint32_t)(n / v);
|
||||
*r = (uint32_t)(n - result * (uint64_t)v);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
@@ -478,9 +478,9 @@ static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v,
|
||||
int s; // Shift amount for norm.
|
||||
|
||||
if (u1 >= v) { // If overflow, set rem.
|
||||
if (r != nullptr) // to an impossible value,
|
||||
*r = static_cast<uint64_t>(-1); // and return the largest
|
||||
return static_cast<uint64_t>(-1);} // possible quotient.
|
||||
if (r != NULL) // to an impossible value,
|
||||
*r = (uint64_t)(-1); // and return the largest
|
||||
return (uint64_t)(-1);} // possible quotient.
|
||||
|
||||
/* count leading zeros */
|
||||
s = libdivide__count_leading_zeros64(v); // 0 <= s <= 63.
|
||||
@@ -513,7 +513,7 @@ again2:
|
||||
rhat = rhat + vn1;
|
||||
if (rhat < b) goto again2;}
|
||||
|
||||
if (r != nullptr) // If remainder is wanted,
|
||||
if (r != NULL) // If remainder is wanted,
|
||||
*r = (un21*b + un0 - q0*v) >> s; // return it.
|
||||
return q1*b + q0;
|
||||
}
|
||||
@@ -770,14 +770,14 @@ __m128i libdivide_u64_do_vector_alg2(__m128i numers, const struct libdivide_u64_
|
||||
static inline int32_t libdivide__mullhi_s32(int32_t x, int32_t y) {
|
||||
int64_t xl = x, yl = y;
|
||||
int64_t rl = xl * yl;
|
||||
return static_cast<int32_t>(rl >> 32); //needs to be arithmetic shift
|
||||
return (int32_t)(rl >> 32); //needs to be arithmetic shift
|
||||
}
|
||||
|
||||
struct libdivide_s32_t libdivide_s32_gen(int32_t d) {
|
||||
struct libdivide_s32_t result;
|
||||
|
||||
/* If d is a power of 2, or negative a power of 2, we have to use a shift. This is especially important because the magic algorithm fails for -1. To check if d is a power of 2 or its inverse, it suffices to check whether its absolute value has exactly one bit set. This works even for INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set and is a power of 2. */
|
||||
uint32_t absD = static_cast<uint32_t>(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick
|
||||
uint32_t absD = (uint32_t)(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick
|
||||
if ((absD & (absD - 1)) == 0) { //check if exactly one bit is set, don't care if absD is 0 since that's divide by zero
|
||||
result.magic = 0;
|
||||
result.more = libdivide__count_trailing_zeros32(absD) | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0) | LIBDIVIDE_S32_SHIFT_PATH;
|
||||
@@ -805,7 +805,7 @@ struct libdivide_s32_t libdivide_s32_gen(int32_t d) {
|
||||
more = floor_log_2_d | LIBDIVIDE_ADD_MARKER | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0); //use the general algorithm
|
||||
}
|
||||
proposed_m += 1;
|
||||
result.magic = (d < 0 ? -static_cast<int32_t>(proposed_m) : static_cast<int32_t>(proposed_m));
|
||||
result.magic = (d < 0 ? -(int32_t)proposed_m : (int32_t)proposed_m);
|
||||
result.more = more;
|
||||
|
||||
}
|
||||
@@ -818,14 +818,14 @@ int32_t libdivide_s32_do(int32_t numer, const struct libdivide_s32_t *denom) {
|
||||
uint8_t shifter = more & LIBDIVIDE_32_SHIFT_MASK;
|
||||
int32_t q = numer + ((numer >> 31) & ((1 << shifter) - 1));
|
||||
q = q >> shifter;
|
||||
int32_t shiftMask = static_cast<int8_t>(more) >> 7; //must be arithmetic shift and then sign-extend
|
||||
int32_t shiftMask = (int8_t)more >> 7; //must be arithmetic shift and then sign-extend
|
||||
q = (q ^ shiftMask) - shiftMask;
|
||||
return q;
|
||||
}
|
||||
else {
|
||||
int32_t q = libdivide__mullhi_s32(denom->magic, numer);
|
||||
if (more & LIBDIVIDE_ADD_MARKER) {
|
||||
int32_t sign = static_cast<int8_t>(more) >> 7; //must be arithmetic shift and then sign extend
|
||||
int32_t sign = (int8_t)more >> 7; //must be arithmetic shift and then sign extend
|
||||
q += ((numer ^ sign) - sign);
|
||||
}
|
||||
q >>= more & LIBDIVIDE_32_SHIFT_MASK;
|
||||
@@ -946,7 +946,7 @@ struct libdivide_s64_t libdivide_s64_gen(int64_t d) {
|
||||
struct libdivide_s64_t result;
|
||||
|
||||
/* If d is a power of 2, or negative a power of 2, we have to use a shift. This is especially important because the magic algorithm fails for -1. To check if d is a power of 2 or its inverse, it suffices to check whether its absolute value has exactly one bit set. This works even for INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set and is a power of 2. */
|
||||
const uint64_t absD = static_cast<uint64_t>(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick
|
||||
const uint64_t absD = (uint64_t)(d < 0 ? -d : d); //gcc optimizes this to the fast abs trick
|
||||
if ((absD & (absD - 1)) == 0) { //check if exactly one bit is set, don't care if absD is 0 since that's divide by zero
|
||||
result.more = libdivide__count_trailing_zeros64(absD) | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0);
|
||||
result.magic = 0;
|
||||
@@ -974,7 +974,7 @@ struct libdivide_s64_t libdivide_s64_gen(int64_t d) {
|
||||
}
|
||||
proposed_m += 1;
|
||||
result.more = more;
|
||||
result.magic = (d < 0 ? -static_cast<int64_t>(proposed_m) : static_cast<int64_t>(proposed_m));
|
||||
result.magic = (d < 0 ? -(int64_t)proposed_m : (int64_t)proposed_m);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -986,14 +986,14 @@ int64_t libdivide_s64_do(int64_t numer, const struct libdivide_s64_t *denom) {
|
||||
uint32_t shifter = more & LIBDIVIDE_64_SHIFT_MASK;
|
||||
int64_t q = numer + ((numer >> 63) & ((1LL << shifter) - 1));
|
||||
q = q >> shifter;
|
||||
int64_t shiftMask = static_cast<int8_t>(more) >> 7; //must be arithmetic shift and then sign-extend
|
||||
int64_t shiftMask = (int8_t)more >> 7; //must be arithmetic shift and then sign-extend
|
||||
q = (q ^ shiftMask) - shiftMask;
|
||||
return q;
|
||||
}
|
||||
else {
|
||||
int64_t q = libdivide__mullhi_s64(magic, numer);
|
||||
if (more & LIBDIVIDE_ADD_MARKER) {
|
||||
int64_t sign = static_cast<int8_t>(more) >> 7; //must be arithmetic shift and then sign extend
|
||||
int64_t sign = (int8_t)more >> 7; //must be arithmetic shift and then sign extend
|
||||
q += ((numer ^ sign) - sign);
|
||||
}
|
||||
q >>= more & LIBDIVIDE_64_SHIFT_MASK;
|
||||
@@ -1141,11 +1141,11 @@ namespace libdivide_internal {
|
||||
#endif
|
||||
|
||||
/* Some bogus unswitch functions for unsigned types so the same (presumably templated) code can work for both signed and unsigned. */
|
||||
uint32_t crash_u32(uint32_t, const libdivide_u32_t *) { abort(); return *static_cast<uint32_t *>(nullptr); }
|
||||
uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *static_cast<uint64_t *>(nullptr); }
|
||||
uint32_t crash_u32(uint32_t, const libdivide_u32_t *) { abort(); return *(uint32_t *)NULL; }
|
||||
uint64_t crash_u64(uint64_t, const libdivide_u64_t *) { abort(); return *(uint64_t *)NULL; }
|
||||
#if LIBDIVIDE_USE_SSE2
|
||||
__m128i crash_u32_vector(__m128i, const libdivide_u32_t *) { abort(); return *(__m128i *)nullptr; }
|
||||
__m128i crash_u64_vector(__m128i, const libdivide_u64_t *) { abort(); return *(__m128i *)nullptr; }
|
||||
__m128i crash_u32_vector(__m128i, const libdivide_u32_t *) { abort(); return *(__m128i *)NULL; }
|
||||
__m128i crash_u64_vector(__m128i, const libdivide_u64_t *) { abort(); return *(__m128i *)NULL; }
|
||||
#endif
|
||||
|
||||
template<typename IntType, typename DenomType, DenomType gen_func(IntType), int get_algo(const DenomType *), IntType do_func(IntType, const DenomType *), MAYBE_VECTOR_PARAM>
|
||||
|
||||
@@ -52,14 +52,14 @@ typedef struct
|
||||
int Malloc_BlocksAlloced; // this shows how many block node chunks have been allocated in Malloc_BlocksMemory
|
||||
} SThreadStorage;
|
||||
|
||||
__thread SThreadStorage *Malloc_ThreadStorage = nullptr;
|
||||
__thread SThreadStorage *Malloc_ThreadStorage = NULL;
|
||||
|
||||
/**E Replace _malloc_init function. */
|
||||
/**J _malloc_init 関数と置き換わる */
|
||||
void user_malloc_init(void)
|
||||
{
|
||||
int res;
|
||||
void *base = nullptr;
|
||||
void *base = NULL;
|
||||
|
||||
/**E Allocate a memory block from the kernel */
|
||||
/**J カーネルからメモリブロックを確保する */
|
||||
@@ -80,7 +80,7 @@ void user_malloc_init(void)
|
||||
/**E Generate mspace */
|
||||
/**J mspace を生成する */
|
||||
s_mspace = mspace_create(base, HEAP_SIZE);
|
||||
if (s_mspace == nullptr) {
|
||||
if (s_mspace == NULL) {
|
||||
/**E Error handling */
|
||||
/**J エラー処理 */
|
||||
sceLibcSetHeapInitError(HEAP_ERROR3);
|
||||
@@ -95,7 +95,7 @@ void user_malloc_finalize(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (s_mspace != nullptr) {
|
||||
if (s_mspace != NULL) {
|
||||
/**E Free mspace */
|
||||
/**J mspace を解放する */
|
||||
res = mspace_destroy(s_mspace);
|
||||
@@ -104,7 +104,7 @@ void user_malloc_finalize(void)
|
||||
/**J エラー処理 */
|
||||
__breakpoint(0);
|
||||
}
|
||||
s_mspace = nullptr;
|
||||
s_mspace = NULL;
|
||||
}
|
||||
|
||||
if (SCE_OK <= s_heapUid) {
|
||||
@@ -125,9 +125,9 @@ void user_malloc_finalize(void)
|
||||
void user_registerthread()
|
||||
{
|
||||
Malloc_ThreadStorage = mspace_malloc(s_mspace, sizeof(SThreadStorage));
|
||||
Malloc_ThreadStorage->Malloc_Blocks = nullptr;
|
||||
Malloc_ThreadStorage->Malloc_Blocks = NULL;
|
||||
Malloc_ThreadStorage->Malloc_BlocksAlloced = 0;
|
||||
Malloc_ThreadStorage->Malloc_MemoryPool = nullptr;
|
||||
Malloc_ThreadStorage->Malloc_MemoryPool = NULL;
|
||||
}
|
||||
|
||||
// before a thread is destroyed make sure we free any space it might be holding on to
|
||||
@@ -157,7 +157,7 @@ void user_removethread()
|
||||
}
|
||||
|
||||
mspace_free(s_mspace, psStorage);
|
||||
Malloc_ThreadStorage = nullptr;
|
||||
Malloc_ThreadStorage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,19 +165,19 @@ void user_removethread()
|
||||
/**J malloc 関数と置き換わる */
|
||||
void *user_malloc(size_t size)
|
||||
{
|
||||
void *p = nullptr;
|
||||
void *p = NULL;
|
||||
|
||||
SThreadStorage *psStorage = Malloc_ThreadStorage;
|
||||
if( psStorage )
|
||||
{
|
||||
// is this the first time we've malloced
|
||||
if( psStorage->Malloc_MemoryPool == nullptr )
|
||||
if( psStorage->Malloc_MemoryPool == NULL )
|
||||
{
|
||||
// create an array of pointers to Block nodes, one pointer for each memory bytes size up to 1036
|
||||
psStorage->Malloc_MemoryPool = mspace_malloc(s_mspace, (MaxRetainedBytes+1) * 4);
|
||||
for( int i = 0;i < (MaxRetainedBytes+1);i += 1 )
|
||||
{
|
||||
psStorage->Malloc_MemoryPool[i] = nullptr;
|
||||
psStorage->Malloc_MemoryPool[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ void user_free(void *ptr)
|
||||
}
|
||||
|
||||
// we need a block node to retain the memory on our stack. do we have any block nodes available
|
||||
if( psStorage->Malloc_Blocks == nullptr )
|
||||
if( psStorage->Malloc_Blocks == NULL )
|
||||
{
|
||||
if( psStorage->Malloc_BlocksAlloced == Malloc_BlocksMemorySize )
|
||||
{
|
||||
@@ -319,7 +319,7 @@ void *user_calloc(size_t nelem, size_t size)
|
||||
/**J realloc 関数と置き換わる */
|
||||
void *user_realloc(void *ptr, size_t size)
|
||||
{
|
||||
void* p = nullptr;
|
||||
void* p = NULL;
|
||||
|
||||
if( Malloc_ThreadStorage )
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ void user_free_for_tls(void *ptr);
|
||||
void user_malloc_for_tls_init(void)
|
||||
{
|
||||
int res;
|
||||
void *base = nullptr;
|
||||
void *base = NULL;
|
||||
|
||||
/**E Allocate a memory block from the kernel */
|
||||
/**J カーネルからメモリブロックを確保する */
|
||||
@@ -48,7 +48,7 @@ void user_malloc_for_tls_init(void)
|
||||
/**E Generate mspace */
|
||||
/**J mspace を生成する */
|
||||
s_mspace = mspace_create(base, HEAP_SIZE);
|
||||
if (s_mspace == nullptr) {
|
||||
if (s_mspace == NULL) {
|
||||
/**E Error handling */
|
||||
/**J エラー処理 */
|
||||
sceLibcSetHeapInitError(HEAP_ERROR3);
|
||||
@@ -63,7 +63,7 @@ void user_malloc_for_tls_finalize(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (s_mspace != nullptr) {
|
||||
if (s_mspace != NULL) {
|
||||
/**E Free mspace */
|
||||
/**J mspace を解放する */
|
||||
res = mspace_destroy(s_mspace);
|
||||
|
||||
@@ -28,13 +28,13 @@ void *user_new(std::size_t size) throw(std::bad_alloc)
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
|
||||
while ((ptr = (void *)std::malloc(size)) == nullptr) {
|
||||
while ((ptr = (void *)std::malloc(size)) == NULL) {
|
||||
/**E Obtain new_handler */
|
||||
/**J new_handler を取得する */
|
||||
std::new_handler handler = std::_get_new_handler();
|
||||
|
||||
/**E When new_handler is a nullptr pointer, bad_alloc is send. If not, new_handler is called. */
|
||||
/**J new_handler が nullptr ポインタの場合、bad_alloc を送出する、そうでない場合、new_handler を呼び出す */
|
||||
/**E When new_handler is a NULL pointer, bad_alloc is send. If not, new_handler is called. */
|
||||
/**J new_handler が NULL ポインタの場合、bad_alloc を送出する、そうでない場合、new_handler を呼び出す */
|
||||
if (!handler)
|
||||
throw std::bad_alloc();
|
||||
else
|
||||
@@ -56,22 +56,22 @@ void *user_new(std::size_t size, const std::nothrow_t& x) throw()
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
|
||||
while ((ptr = (void *)std::malloc(size)) == nullptr) {
|
||||
while ((ptr = (void *)std::malloc(size)) == NULL) {
|
||||
/**E Obtain new_handler */
|
||||
/**J new_handler を取得する */
|
||||
std::new_handler handler = std::_get_new_handler();
|
||||
|
||||
/**E When new_handler is a nullptr pointer, nullptr is returned. */
|
||||
/**J new_handler が nullptr ポインタの場合、nullptr を返す */
|
||||
/**E When new_handler is a NULL pointer, NULL is returned. */
|
||||
/**J new_handler が NULL ポインタの場合、NULL を返す */
|
||||
if (!handler)
|
||||
return nullptr;
|
||||
return NULL;
|
||||
|
||||
/**E Call new_handler. If new_handler sends bad_alloc, nullptr is returned. */
|
||||
/**J new_handler を呼び出す、new_handler が bad_alloc を送出した場合、nullptr を返す */
|
||||
/**E Call new_handler. If new_handler sends bad_alloc, NULL is returned. */
|
||||
/**J new_handler を呼び出す、new_handler が bad_alloc を送出した場合、NULL を返す */
|
||||
try {
|
||||
(*handler)();
|
||||
} catch (std::bad_alloc) {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
@@ -98,9 +98,9 @@ void *user_new_array(std::size_t size, const std::nothrow_t& x) throw()
|
||||
void user_delete(void *ptr) throw()
|
||||
{
|
||||
// SCE_DBG_LOG_TRACE("Called operator delete(%p)", ptr);
|
||||
/**E In the case of the nullptr pointer, no action will be taken. */
|
||||
/**J nullptr ポインタの場合、何も行わない */
|
||||
if (ptr != nullptr)
|
||||
/**E In the case of the NULL pointer, no action will be taken. */
|
||||
/**J NULL ポインタの場合、何も行わない */
|
||||
if (ptr != NULL)
|
||||
std::free(ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ typedef struct z_stream_s {
|
||||
uInt avail_out; /* remaining free space at next_out */
|
||||
uLong total_out; /* total number of bytes output so far */
|
||||
|
||||
z_const char *msg; /* last error message, nullptr if no error */
|
||||
z_const char *msg; /* last error message, NULL if no error */
|
||||
struct internal_state FAR *state; /* not visible by applications */
|
||||
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
@@ -1254,7 +1254,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||
reading, this will be detected automatically by looking for the magic two-
|
||||
byte gzip header.
|
||||
|
||||
gzopen returns nullptr if the file could not be opened, if there was
|
||||
gzopen returns NULL if the file could not be opened, if there was
|
||||
insufficient memory to allocate the gzFile state, or if an invalid mode was
|
||||
specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
|
||||
errno can be checked to determine if the reason gzopen failed was that the
|
||||
@@ -1277,7 +1277,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||
close the associated file descriptor, so they need to have different file
|
||||
descriptors.
|
||||
|
||||
gzdopen returns nullptr if there was insufficient memory to allocate the
|
||||
gzdopen returns NULL if there was insufficient memory to allocate the
|
||||
gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
|
||||
provided, or '+' was provided), or if fd is -1. The file descriptor is not
|
||||
used until the next gz* read, write, seek, or close operation, so gzdopen
|
||||
@@ -1377,7 +1377,7 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||
string is terminated with a null character. If no characters are read due
|
||||
to an end-of-file or len < 1, then the buffer is left untouched.
|
||||
|
||||
gzgets returns buf which is a null-terminated string, or it returns nullptr
|
||||
gzgets returns buf which is a null-terminated string, or it returns NULL
|
||||
for end-of-file or in case of error. If there was an error, the contents at
|
||||
buf are indeterminate.
|
||||
*/
|
||||
@@ -1393,7 +1393,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||
Reads one byte from the compressed file. gzgetc returns this byte or -1
|
||||
in case of end of file or error. This is implemented as a macro for speed.
|
||||
As such, it does not do all of the checking the other functions do. I.e.
|
||||
it does not check to see if file is nullptr, nor whether the structure file
|
||||
it does not check to see if file is NULL, nor whether the structure file
|
||||
points to has been clobbered or not.
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user