1
0
forked from 0ad/0ad

more dehydra. disabled lockfree module (not in use).

This was SVN commit r6240.
This commit is contained in:
janwas 2008-07-17 17:00:00 +00:00
parent 8e86d29301
commit fe6370aff8
27 changed files with 76 additions and 55 deletions

View File

@ -36,10 +36,12 @@ I18n::StringBuffer::operator Str()
}
if (String->VarCount == 0)
{
if (String->Parts.size())
return String->Parts[0]->ToString(Locale, Variables).str();
else
return Str();
}
Str ret;

View File

@ -368,7 +368,8 @@ public:
FileInfo fileInfo;
s_fileSystemPosix.GetFileInfo(pathname, &fileInfo);
m_fileSize = fileInfo.Size();
debug_assert(m_fileSize >= sizeof(LFH)+sizeof(CDFH)+sizeof(ECDR));
const size_t minFileSize = sizeof(LFH)+sizeof(CDFH)+sizeof(ECDR);
debug_assert(m_fileSize >= off_t(minFileSize));
}
virtual LibError ReadEntries(ArchiveEntryCallback cb, uintptr_t cbData)

View File

@ -42,7 +42,7 @@ static size_t io_seeks;
static size_t cache_count[2];
static double cache_size_total[2];
static size_t conflict_misses;
static double conflict_miss_size_total;
//static double conflict_miss_size_total; // JW: currently not used nor computed
static size_t block_cache_count[2];
// archive builder

View File

@ -32,7 +32,7 @@ BlockId::BlockId(const Path& pathname, off_t ofs)
const size_t indexBits = 16;
m_id <<= indexBits;
const off_t blockIndex = ofs / BLOCK_SIZE;
debug_assert(blockIndex < (1ul << indexBits));
debug_assert(blockIndex < off_t(1ul << indexBits));
m_id |= blockIndex;
}

View File

@ -9,6 +9,7 @@
// license: GPL; see lib/license.txt
#include "precompiled.h"
#if 0 // JW: disabled, not used
#include "lockfree.h"
#include <set>
@ -258,7 +259,7 @@ retry:
// for each participating thread:
for(TLS* t = tls_list; t; t = t->next)
// for each of its non-NULL hazard pointers:
for(int i = 0; i < NUM_HPS; i++)
for(size_t i = 0; i < NUM_HPS; i++)
{
void* hp = t->hp[i];
if(!hp)
@ -707,3 +708,5 @@ void lockfree_Shutdown()
smr_shutdown();
}
#endif

View File

@ -37,6 +37,7 @@ static LibError load_sys_cursor(const VfsPath& pathname, int hx, int hy, sys_cur
UNUSED2(pathname);
UNUSED2(hx);
UNUSED2(hy);
UNUSED2(cursor);
return ERR::FAIL;
#else
@ -115,7 +116,7 @@ public:
LibError validate() const
{
const size_t A = 128; // no cursor is expected to get this big
const GLint A = 128; // no cursor is expected to get this big
if(w > A || h > A || hotspotx > A || hotspoty > A)
WARN_RETURN(ERR::_1);
if(ht < 0)

View File

@ -181,7 +181,10 @@ static LibError UniFont_validate(const UniFont* f)
static LibError UniFont_to_string(const UniFont* f, char* buf)
{
if (f->ht) // not true if this is called after dtor (which it is)
snprintf(buf, H_STRING_LEN, "Font %s", h_filename(f->ht));
{
const VfsPath& path = h_filename(f->ht);
snprintf(buf, H_STRING_LEN, "Font %s", path.string().c_str());
}
else
snprintf(buf, H_STRING_LEN, "Font");
return INFO::OK;

View File

@ -109,6 +109,7 @@ LibError dir_get_changed_file(char* fn)
char n_path[PATH_MAX];
const char* dir = dirs[e.fr.reqnum].c_str();
snprintf(n_path, PATH_MAX, "%s%c%s", dir, SYS_DIR_SEP, e.filename);
UNUSED2(fn); // we ought to copy to fn, but this code is apparently disabled..
return ERR::AGAIN;
}
}

View File

@ -9,6 +9,10 @@
class TestLockfreeBasic : public CxxTest::TestSuite
{
public:
// note: the lockfree module is no longer part of the build, but cxxtestgen
// still sees this class and its methods despite them being commented out
// (#if 0 doesn't help, either). we therefore need to disable their bodies.
#if 0
void setUp()
{
lockfree_Init();
@ -18,9 +22,11 @@ public:
{
lockfree_Shutdown();
}
#endif
void test_basic_single_threaded()
{
#if 0
void* user_data;
const size_t ENTRIES = 50;
// should be more than max # retired nodes to test release..() code
@ -61,6 +67,7 @@ public:
lfl_free(&list);
lfh_free(&hash);
#endif
}
};
@ -68,6 +75,7 @@ public:
// known to fail on P4 due to mem reordering and lack of membars.
class TestMultithread : public CxxTest::TestSuite
{
#if 0
void setUp()
{
lockfree_Init();
@ -247,4 +255,5 @@ public:
lfh_free(&hash);
TS_ASSERT_OK(pthread_mutex_destroy(&mutex));
}
#endif
};

View File

@ -358,7 +358,7 @@ void kill_mainloop()
// moved into a helper function to ensure args is destroyed before
// exit(), which may result in a memory leak.
static void RunGameOrAtlas(int argc, char* argv[])
static void RunGameOrAtlas(int argc, const char* argv[])
{
CmdLineArgs args(argc, argv);
@ -386,7 +386,7 @@ int main(int argc, char* argv[])
{
EarlyInit(); // must come at beginning of main
RunGameOrAtlas(argc, argv);
RunGameOrAtlas(argc, const_cast<const char**>(argv));
exit(EXIT_SUCCESS);
}

View File

@ -520,12 +520,16 @@ CStr CStr::Pad(PS_TRIM_MODE Mode, size_t Length) const
CStr CStr::operator+(const CStr& Str)
{
return std::operator+(*this, std::tstring(Str));
CStr tmp(*this);
tmp += Str;
return tmp;
}
CStr CStr::operator+(const tchar* Str)
{
return std::operator+(*this, std::tstring(Str));
CStr tmp(*this);
tmp += Str;
return tmp;
}
// Joining ASCII and Unicode strings:

View File

@ -2,7 +2,7 @@
#include "CmdLineArgs.h"
CmdLineArgs::CmdLineArgs(int argc, char* argv[])
CmdLineArgs::CmdLineArgs(int argc, const char* argv[])
{
if (argc >= 1)
m_Arg0 = argv[0];

View File

@ -16,7 +16,7 @@ public:
* @param argc size of argv array
* @param argv array of arguments; argv[0] should be the program's name
*/
CmdLineArgs(int argc, char* argv[]);
CmdLineArgs(int argc, const char* argv[]);
/**
* Test whether the given name was specified, as either <tt>-name</tt> or

View File

@ -56,7 +56,7 @@ CStr g_AutostartMap = "";
static void LoadProfile( const CStr& profile )
{
VfsPath path = VfsPath("profiles") / (std::string)profile;
VfsPath path = VfsPath("profiles") / profile;
VfsPath configFilename = path / "settings/user.cfg";
g_ConfigDB.SetConfigFile(CFG_USER, true, configFilename.string().c_str());

View File

@ -827,8 +827,6 @@ void Shutdown(int flags)
SAFE_DELETE(g_Logger);
delete &g_Profiler;
delete &g_ProfileViewer;
lockfree_Shutdown();
TIMER_END("shutdown misc");
}
@ -843,8 +841,6 @@ void EarlyInit()
// add all debug_printf "tags" that we are interested in:
debug_filter_add("TIMER");
lockfree_Init();
cpu_ConfigureFloatingPoint();
timer_LatchStartTime();

View File

@ -7,7 +7,7 @@ class TestCmdLineArgs : public CxxTest::TestSuite
public:
void test_has()
{
char* argv[] = { "program", "-test2" };
const char* argv[] = { "program", "-test2" };
CmdLineArgs c(ARRAY_SIZE(argv), argv);
TS_ASSERT(!c.Has("test1"));
TS_ASSERT(c.Has("test2"));
@ -17,7 +17,7 @@ public:
void test_get()
{
char* argv[] = { "program", "-test1=", "-test2=x", "-test3=-y=y-", "-=z" };
const char* argv[] = { "program", "-test1=", "-test2=x", "-test3=-y=y-", "-=z" };
CmdLineArgs c(ARRAY_SIZE(argv), argv);
TS_ASSERT_STR_EQUALS(c.Get("test0"), "");
TS_ASSERT_STR_EQUALS(c.Get("test1"), "");
@ -28,7 +28,7 @@ public:
void test_multiple()
{
char* argv[] = { "program", "-test1=one", "-test1=two", "-test2=none", "-test1=three" };
const char* argv[] = { "program", "-test1=one", "-test1=two", "-test2=none", "-test1=three" };
CmdLineArgs c(ARRAY_SIZE(argv), argv);
TS_ASSERT_STR_EQUALS(c.Get("test1"), "one");
@ -48,7 +48,7 @@ public:
void test_get_invalid()
{
char* argv[] = { "-test1", "-test2", "test3", " -test4" };
const char* argv[] = { "-test1", "-test2", "test3", " -test4" };
CmdLineArgs c(ARRAY_SIZE(argv), argv);
TS_ASSERT(!c.Has("test1"));
@ -59,7 +59,7 @@ public:
void test_arg0()
{
char* argv[] = { "program" };
const char* argv[] = { "program" };
CmdLineArgs c(ARRAY_SIZE(argv), argv);
TS_ASSERT_STR_EQUALS(c.GetArg0(), "program");

View File

@ -89,7 +89,7 @@ void WriteSystemInfo()
fprintf(f, "\n");
// memory
fprintf(f, "Memory : %lu MiB; %lu MiB free\n", os_cpu_MemorySize()/MiB, os_cpu_MemoryAvailable()/MiB);
fprintf(f, "Memory : %u MiB; %u MiB free\n", os_cpu_MemorySize(), os_cpu_MemoryAvailable());
// graphics
fprintf(f, "Graphics Card : %s\n", gfx_card);

View File

@ -228,7 +228,7 @@ PSRETURN CXeromyces::Load(const VfsPath& filename)
if (errorHandler.GetSawErrors())
{
LOG(CLogger::Error, LOG_CATEGORY, "CXeromyces: Errors in XML file '%s'", filename);
LOG(CLogger::Error, LOG_CATEGORY, "CXeromyces: Errors in XML file '%s'", filename.string().c_str());
return PSRETURN_Xeromyces_XMLParseError;
// The internal tree of the XeroHandler will be cleaned up automatically
}

View File

@ -45,7 +45,7 @@ public:
char random[1021];
std::vector<CVector2D> aPath;
void setPath(std::vector<CVector2D> _aPath)
void setPath(const std::vector<CVector2D>& _aPath)
{
aPath =_aPath;
@ -269,7 +269,7 @@ bool CAStarEngine::FindPath(
//switch on/off grid path drawing by command line arg "-showOverlay"
//it's guarded here to stop setting the drawing path in pathfindingOverlay.
//(efficiency issue)
//the drawing is disable in the render() function in TerraiOverlay.cpp
//the drawing is disabled in the render() function in TerrainOverlay.cpp
if(g_ShowPathfindingOverlay)
{
pathfindingOverlay->setPath(mPath);

View File

@ -12,9 +12,9 @@ CHandle::CHandle()
m_refcount = 0;
}
HEntity::HEntity( u16 index )
HEntity::HEntity( size_t index )
{
m_handle = index;
m_handle = (u16)index;
AddRef();
}

View File

@ -42,7 +42,7 @@ class HEntity
private:
void AddRef();
void DecRef();
HEntity( u16 index );
HEntity( size_t index );
public:
HEntity();
HEntity( const HEntity& copy );

View File

@ -44,7 +44,7 @@ CEntityManager::CEntityManager()
void CEntityManager::DeleteAllHelper()
{
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
{
if( m_entities[i].m_refcount )
{
@ -195,7 +195,7 @@ HEntity CEntityManager::Create(CEntityTemplate* base, CVector3D position, float
return HEntity();
// Find an unused handle for the unit
int pos = 0;
size_t pos = 0;
while( m_entities[m_nextalloc].m_refcount )
{
m_nextalloc++;
@ -272,13 +272,13 @@ HEntity CEntityManager::CreateFoundation( const CStrW& templateName, CPlayer* pl
return Create( foundation, position, orientation, selections, &templateName );
}
HEntity* CEntityManager::GetByHandle( u16 index )
HEntity* CEntityManager::GetByHandle( size_t index )
{
if( index >= MAX_HANDLES ) return( NULL );
if( !m_entities[index].m_refcount ) return( NULL );
return( new HEntity( index ) );
}
CHandle *CEntityManager::GetHandle( int index )
CHandle *CEntityManager::GetHandle( size_t index )
{
if (!m_entities[index].m_refcount )
return NULL;
@ -288,7 +288,7 @@ CHandle *CEntityManager::GetHandle( int index )
void CEntityManager::GetMatchingAsHandles(std::vector<HEntity>& matchlist, EntityPredicate predicate, void* userdata)
{
matchlist.clear();
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
{
if( IsEntityRefd(i) )
if( predicate( m_entities[i].m_entity, userdata ) )
@ -299,7 +299,7 @@ void CEntityManager::GetMatchingAsHandles(std::vector<HEntity>& matchlist, Entit
void CEntityManager::GetExtantAsHandles( std::vector<HEntity>& results )
{
results.clear();
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( IsEntityRefd(i) )
results.push_back( HEntity( i ) );
}
@ -307,7 +307,7 @@ void CEntityManager::GetExtantAsHandles( std::vector<HEntity>& results )
void CEntityManager::GetExtant( std::vector<CEntity*>& results )
{
results.clear();
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant )
results.push_back( m_entities[i].m_entity );
}
@ -356,7 +356,7 @@ void CEntityManager::GetInLOS( CEntity* entity, std::vector<CEntity*>& results )
/*
void CEntityManager::dispatchAll( CMessage* msg )
{
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( m_entities[i].m_refcount && m_entities[i].m_entity->m_extant )
m_entities[i].m_entity->dispatch( msg );
}
@ -374,7 +374,7 @@ void CEntityManager::InitializeAll()
debug_assert(! m_collisionPatches);
m_collisionPatches = new std::vector<CEntity*>[m_collisionPatchesPerSide * m_collisionPatchesPerSide];
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
{
if( IsEntityRefd(i) )
{
@ -391,7 +391,7 @@ void CEntityManager::InitializeAll()
/*
void CEntityManager::TickAll()
{
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant )
m_entities[i].m_entity->Tick();
}
@ -421,7 +421,7 @@ void CEntityManager::UpdateAll( int timestep )
*/
PROFILE_START( "update all" );
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( IsEntityRefd(i) )
m_entities[i].m_entity->Update( timestep );
PROFILE_END( "update all" );
@ -429,7 +429,7 @@ void CEntityManager::UpdateAll( int timestep )
void CEntityManager::InterpolateAll( float relativeoffset )
{
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
// This needs to handle all entities, including destroyed/non-extant ones
// (mainly dead bodies), so it can't use IsEntityRefd
if( m_entities[i].m_refcount )
@ -438,7 +438,7 @@ void CEntityManager::InterpolateAll( float relativeoffset )
void CEntityManager::RenderAll()
{
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( IsEntityRefd(i) )
m_entities[i].m_entity->Render();
}
@ -446,7 +446,7 @@ void CEntityManager::RenderAll()
void CEntityManager::ConformAll()
{
PROFILE_START("conform all");
for ( int i=0; i < MAX_HANDLES; i++ )
for ( size_t i=0; i < MAX_HANDLES; i++ )
{
if( IsEntityRefd(i) )
{
@ -459,7 +459,7 @@ void CEntityManager::ConformAll()
void CEntityManager::InvalidateAll()
{
for( int i = 0; i < MAX_HANDLES; i++ )
for( size_t i = 0; i < MAX_HANDLES; i++ )
if( IsEntityRefd(i) )
m_entities[i].m_entity->InvalidateActor();
}
@ -477,7 +477,7 @@ void CEntityManager::RemoveUnitCount(CEntity* ent)
}
--m_entityClassData[playerID][className];
}
void CEntityManager::Destroy( u16 handle )
void CEntityManager::Destroy( size_t handle )
{
m_reaper.push_back( m_entities[handle].m_entity );
}

View File

@ -55,10 +55,10 @@ friend class CHandle;
//Optimized data for triggers. key = playerID, nested key = entity class, value = frequency
std::map<size_t, std::map<CStrW, int> > m_entityClassData;
void Destroy( u16 handle );
void Destroy( size_t handle );
void DeleteAllHelper();
inline bool IsEntityRefd( u16 index )
inline bool IsEntityRefd( size_t index )
{
return m_refd[index];
//return m_entities[index].m_refcount && !m_entities[index].m_entity->entf_get(ENTF_DESTROYED);
@ -79,8 +79,8 @@ public:
HEntity CreateFoundation( const CStrW& templateName, CPlayer* player, CVector3D position,
float orientation );
HEntity* GetByHandle( u16 index );
CHandle *GetHandle( int index );
HEntity* GetByHandle( size_t index );
CHandle *GetHandle( size_t index );
inline int GetPlayerUnitCount( size_t player, const CStrW& name )
{

View File

@ -192,8 +192,9 @@ bool CFormation::LoadXml(const CStr& filename)
return true;
}
void CFormation::AssignCategory(size_t order, CStr category)
void CFormation::AssignCategory(size_t order, const CStr& category_)
{
CStr category(category_);
category.Remove( CStr(",") );
category = category + " "; //So the final word will be pushed as well
CStr temp;

View File

@ -75,6 +75,6 @@ private:
std::map<size_t, FormationSlot> m_slots;
bool LoadXml(const CStr& filename);
void AssignCategory(size_t order, CStr category); //takes care of formatting strings
void AssignCategory(size_t order, const CStr& category); //takes care of formatting strings
};
#endif

View File

@ -109,17 +109,17 @@ public:
}
}
void setCurrentPath(SrPolygon _CurPath)
void setCurrentPath(const SrPolygon& _CurPath)
{
CurPath = _CurPath;
}
void setConstrainedEdges(SrArray<SrPnt2> _constr)
void setConstrainedEdges(const SrArray<SrPnt2>& _constr)
{
constr = _constr;
}
void setUnconstrainedEdges(SrArray<SrPnt2> _unconstr)
void setUnconstrainedEdges(const SrArray<SrPnt2>& _unconstr)
{
unconstr = _unconstr;
}

View File

@ -12,7 +12,7 @@ CTRAStarEngine::~CTRAStarEngine(void)
delete mGoal;
}
bool CTRAStarEngine::FindPath(const CVector2D &src, const CVector2D &dest, HEntity entity, SeDcdt& dcdtPathfinder, float radius )
bool CTRAStarEngine::FindPath(const CVector2D &src, const CVector2D &dest, HEntity UNUSED(entity), SeDcdt& dcdtPathfinder, float radius )
{
bool found = dcdtPathfinder.SearchPathFast(src.x, src.y, dest.x, dest.y, radius);
return found;