"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "system/SetupSystem.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

SetupSystem.cpp  (muscle8.20):SetupSystem.cpp  (muscle8.30)
skipping to change at line 733 skipping to change at line 733
#if defined(MUSCLE_USE_POWERPC_INLINE_ASSEMBLY) && defined (MUSCLE_POWERPC_TIMEB ASE_HZ) #if defined(MUSCLE_USE_POWERPC_INLINE_ASSEMBLY) && defined (MUSCLE_POWERPC_TIMEB ASE_HZ)
static inline uint32 get_tbl() {uint32 tbl; asm volatile("mftb %0" : "=r" (tbl) :); return tbl;} static inline uint32 get_tbl() {uint32 tbl; asm volatile("mftb %0" : "=r" (tbl) :); return tbl;}
static inline uint32 get_tbu() {uint32 tbu; asm volatile("mftbu %0" : "=r" (tbu) :); return tbu;} static inline uint32 get_tbu() {uint32 tbu; asm volatile("mftbu %0" : "=r" (tbu) :); return tbu;}
#endif #endif
/** Defined here since every MUSCLE program will have to include this file anywa y... */ /** Defined here since every MUSCLE program will have to include this file anywa y... */
static uint64 GetRunTime64Aux() static uint64 GetRunTime64Aux()
{ {
#if defined(__BEOS__) || defined(__HAIKU__) #if defined(__BEOS__) || defined(__HAIKU__)
return return system_time(); return system_time();
#elif defined(TARGET_PLATFORM_XENOMAI) && !defined(MUSCLE_AVOID_XENOMAI) #elif defined(TARGET_PLATFORM_XENOMAI) && !defined(MUSCLE_AVOID_XENOMAI)
return rt_timer_tsc2ns(rt_timer_tsc())/1000; return rt_timer_tsc2ns(rt_timer_tsc())/1000;
#elif defined(WIN32) #elif defined(WIN32)
uint64 ret = 0; uint64 ret = 0;
if (_rtMutex.Lock().IsOK()) if (_rtMutex.Lock().IsOK())
{ {
# ifdef MUSCLE_USE_QUERYPERFORMANCECOUNTER # ifdef MUSCLE_USE_QUERYPERFORMANCECOUNTER
if (_qpcTicksPerSecond == 0) InitClockFrequency(); // in case we got call ed before main() if (_qpcTicksPerSecond == 0) InitClockFrequency(); // in case we got call ed before main()
static int64 _brokenQPCOffset = 0; static int64 _brokenQPCOffset = 0;
skipping to change at line 822 skipping to change at line 822
return ((((uint64)newTicks)*MICROS_PER_SECOND)/_posixTicksPerSecond); return ((((uint64)newTicks)*MICROS_PER_SECOND)/_posixTicksPerSecond);
} }
else else
{ {
// Oops, clock_t is skinny enough that it might wrap. So we need to watch for that. // Oops, clock_t is skinny enough that it might wrap. So we need to watch for that.
if (_rtMutex.Lock().IsOK()) if (_rtMutex.Lock().IsOK())
{ {
static uint32 _prevVal; static uint32 _prevVal;
static uint64 _wrapOffset = 0; static uint64 _wrapOffset = 0;
struct tms junk; clock_t newTicks = (clock_t) times(&junk); struct tms junk = {0}; clock_t newTicks = (clock_t) times(&junk);
const uint32 newVal = (uint32) newTicks; const uint32 newVal = (uint32) newTicks;
if (newVal < _prevVal) _wrapOffset += (((uint64)1)<<32); if (newVal < _prevVal) _wrapOffset += (((uint64)1)<<32);
const uint64 ret = ((_wrapOffset+newVal)*MICROS_PER_SECOND)/_posixTicks PerSecond; // convert to microseconds const uint64 ret = ((_wrapOffset+newVal)*MICROS_PER_SECOND)/_posixTicks PerSecond; // convert to microseconds
_prevVal = newTicks; _prevVal = newTicks;
_rtMutex.Unlock(); _rtMutex.Unlock();
return ret; return ret;
} }
else return 0; // Oops? else return 0; // Oops?
} }
skipping to change at line 1886 skipping to change at line 1886
_firstObjectCounter = this; _firstObjectCounter = this;
} }
void ObjectCounterBase :: RemoveObjectCounterBaseFromGlobalCountersList() void ObjectCounterBase :: RemoveObjectCounterBaseFromGlobalCountersList()
{ {
if (_firstObjectCounter == this) _firstObjectCounter = _nextCounter; if (_firstObjectCounter == this) _firstObjectCounter = _nextCounter;
if (_prevCounter) _prevCounter->_nextCounter = _nextCounter; if (_prevCounter) _prevCounter->_nextCounter = _nextCounter;
if (_nextCounter) _nextCounter->_prevCounter = _prevCounter; if (_nextCounter) _nextCounter->_prevCounter = _prevCounter;
} }
ObjectCounterBase :: ObjectCounterBase() ObjectCounterBase :: ObjectCounterBase(const char * objectCounterTypeName, uint3
: _prevCounter(NULL) 2 sizeofObject)
: _objectCounterTypeName(objectCounterTypeName)
, _sizeofObject(sizeofObject)
, _prevCounter(NULL)
, _nextCounter(NULL) , _nextCounter(NULL)
{ {
if (_muscleLock) if (_muscleLock)
{ {
MutexGuard mg(*_muscleLock); MutexGuard mg(*_muscleLock);
PrependObjectCounterBaseToGlobalCountersList(); PrependObjectCounterBaseToGlobalCountersList();
} }
else PrependObjectCounterBaseToGlobalCountersList(); else PrependObjectCounterBaseToGlobalCountersList();
} }
skipping to change at line 1910 skipping to change at line 1912
if (_muscleLock) if (_muscleLock)
{ {
MutexGuard mg(*_muscleLock); MutexGuard mg(*_muscleLock);
RemoveObjectCounterBaseFromGlobalCountersList(); RemoveObjectCounterBaseFromGlobalCountersList();
} }
else RemoveObjectCounterBaseFromGlobalCountersList(); else RemoveObjectCounterBaseFromGlobalCountersList();
} }
#endif #endif
status_t GetCountedObjectInfo(Hashtable<const char *, uint32> & results) status_t GetCountedObjectInfo(Hashtable<const char *, uint64> & results)
{ {
#ifdef MUSCLE_ENABLE_OBJECT_COUNTING #ifdef MUSCLE_ENABLE_OBJECT_COUNTING
Mutex * m = _muscleLock; Mutex * m = _muscleLock;
if ((m==NULL)||(m->Lock().IsOK())) if ((m==NULL)||(m->Lock().IsOK()))
{ {
status_t ret; status_t ret;
const ObjectCounterBase * oc = _firstObjectCounter; const ObjectCounterBase * oc = _firstObjectCounter;
while(oc) while(oc)
{ {
(void) results.Put(oc->GetCounterTypeName(), oc->GetCount()).IsError(re t); (void) results.Put(oc->GetCounterTypeName(), (((uint64)oc->GetSizeofObj ect())<<32)|((uint64)oc->GetCount())).IsError(ret);
oc = oc->GetNextCounter(); oc = oc->GetNextCounter();
} }
if (m) m->Unlock(); if (m) m->Unlock();
return ret; return ret;
} }
else return B_LOCK_FAILED; else return B_LOCK_FAILED;
#else #else
(void) results; (void) results;
return B_UNIMPLEMENTED; return B_UNIMPLEMENTED;
#endif #endif
} }
class CompareSizesFunctor
{
public:
int Compare(const uint64 & v1, const uint64 & v2, void *) const
{
const uint32 objCount1 = ((v1>>00) & 0xFFFFFFFF);
const uint32 objCount2 = ((v2>>00) & 0xFFFFFFFF);
const uint32 objSize1 = ((v1>>32) & 0xFFFFFFFF);
const uint32 objSize2 = ((v2>>32) & 0xFFFFFFFF);
return muscleCompare(((uint64)objSize1)*((uint64)objCount1), ((uint64)objS
ize2)*((uint64)objCount2));
}
};
void PrintCountedObjectInfo() void PrintCountedObjectInfo()
{ {
#ifdef MUSCLE_ENABLE_OBJECT_COUNTING #ifdef MUSCLE_ENABLE_OBJECT_COUNTING
Hashtable<const char *, uint32> table; uint64 totalNumObjects = 0;
uint64 totalNumBytes = 0;
Hashtable<const char *, uint64> table;
if (GetCountedObjectInfo(table).IsOK()) if (GetCountedObjectInfo(table).IsOK())
{ {
table.SortByKey(); // so they'll be printed in alphabetical order table.SortByValue(CompareSizesFunctor()); // so they'll be printed in alp
printf("Counted Object Info report follows: (" UINT32_FORMAT_SPEC " types habetical order
counted)\n", table.GetNumItems()); for (HashtableIterator<const char *, uint64> iter(table, HTIT_FLAG_BACKWAR
for (HashtableIterator<const char *, uint32> iter(table); iter.HasData(); DS); iter.HasData(); iter++)
iter++) printf(" %6" UINT32_FORMAT_SPEC_NOPERCENT " %s\n", iter.GetValue(), it {
er.GetKey()); const uint64 v = iter.GetValue();
const uint32 objSize = ((v>>32) & 0xFFFFFFFF);
const uint32 objCount = ((v>>00) & 0xFFFFFFFF);
totalNumObjects += objCount;
totalNumBytes += ((uint64)objSize)*((uint64)objCount);
}
printf("Counted Object Info report follows: (" UINT32_FORMAT_SPEC " types
counted, " UINT64_FORMAT_SPEC " total objects, %.02f total MB, average " UINT64_
FORMAT_SPEC " bytes/object)\n", table.GetNumItems(), totalNumObjects, ((double)t
otalNumBytes)/(1024*1024), (totalNumObjects>0)?(totalNumBytes/totalNumObjects):0
LL);
for (HashtableIterator<const char *, uint64> iter(table, HTIT_FLAG_BACKWAR
DS); iter.HasData(); iter++)
{
const uint64 v = iter.GetValue();
const uint32 objSize = ((v>>32) & 0xFFFFFFFF);
const uint32 objCount = ((v>>00) & 0xFFFFFFFF);
printf(" %6" UINT32_FORMAT_SPEC_NOPERCENT " %s (" UINT32_FORMAT_SPEC
" bytes/object, %ikB used))\n", objCount, iter.GetKey(), objSize, (int)((512+(((
uint64)objSize)*((uint64)objCount)))/1024));
}
} }
else printf("PrintCountedObjectInfo: GetCountedObjectInfo() failed!\n"); else printf("PrintCountedObjectInfo: GetCountedObjectInfo() failed!\n");
#else #else
printf("Counted Object Info report not available, because MUSCLE was compiled without -DMUSCLE_ENABLE_OBJECT_COUNTING\n"); printf("Counted Object Info report not available, because MUSCLE was compiled without -DMUSCLE_ENABLE_OBJECT_COUNTING\n");
#endif #endif
} }
void SetMainReflectServerCatchSignals(bool enable) void SetMainReflectServerCatchSignals(bool enable)
{ {
_mainReflectServerCatchSignals = enable; _mainReflectServerCatchSignals = enable;
 End of changes. 8 change blocks. 
13 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)