Skip to content
Snippets Groups Projects
Commit e11253d4 authored by Axel Naumann's avatar Axel Naumann
Browse files

Outline functions to remove mmalloc from interface; not perf critical.

parent 69257729
Branches
Tags
No related merge requests found
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
#ifndef ROOT_TROOT #ifndef ROOT_TROOT
#include "TROOT.h" #include "TROOT.h"
#endif #endif
#if !defined(__MMPRIVATE_H) && !defined(__CINT__)
#include "mmprivate.h"
#endif
class TBrowser; class TBrowser;
class TDirectory; class TDirectory;
...@@ -159,34 +155,6 @@ public: ...@@ -159,34 +155,6 @@ public:
TMapRec *GetNext(Long_t offset = 0) const { return (TMapRec *)((Long_t) fNext + offset); } TMapRec *GetNext(Long_t offset = 0) const { return (TMapRec *)((Long_t) fNext + offset); }
}; };
////////////////////////////////////////////////////////////////////////////////
/// Return the current location in the memory region for this malloc heap which
/// represents the end of memory in use. Returns 0 if map file was closed.
inline void *TMapFile::GetBreakval() const
{
if (!fMmallocDesc) return 0;
return (void *)((struct mdesc *)fMmallocDesc)->breakval;
}
////////////////////////////////////////////////////////////////////////////////
inline TMapFile *TMapFile::WhichMapFile(void *addr)
{
if (!gROOT || !gROOT->GetListOfMappedFiles()) return 0;
TObjLink *lnk = ((TList *)gROOT->GetListOfMappedFiles())->LastLink();
while (lnk) {
TMapFile *mf = (TMapFile*)lnk->GetObject();
if (!mf) return 0;
if ((ULong_t)addr >= mf->fBaseAddr + mf->fOffset &&
(ULong_t)addr < (ULong_t)mf->GetBreakval() + mf->fOffset)
return mf;
lnk = lnk->Prev();
}
return 0;
}
R__EXTERN void *gMmallocDesc; //is initialized in TClass.cxx R__EXTERN void *gMmallocDesc; //is initialized in TClass.cxx
#endif #endif
...@@ -96,6 +96,8 @@ robust Streamer mechanism I opted for 3). ...@@ -96,6 +96,8 @@ robust Streamer mechanism I opted for 3).
#include "TClass.h" #include "TClass.h"
#include "TBufferFile.h" #include "TBufferFile.h"
#include "TVirtualMutex.h" #include "TVirtualMutex.h"
#include "mmprivate.h"
#include <cmath> #include <cmath>
#if defined(R__UNIX) && !defined(R__MACOSX) && !defined(R__WINGCC) #if defined(R__UNIX) && !defined(R__MACOSX) && !defined(R__WINGCC)
...@@ -1088,6 +1090,15 @@ Int_t TMapFile::GetBestBuffer() ...@@ -1088,6 +1090,15 @@ Int_t TMapFile::GetBestBuffer()
return (Int_t)(mean + std::sqrt(rms2)); return (Int_t)(mean + std::sqrt(rms2));
} }
////////////////////////////////////////////////////////////////////////////////
/// Return the current location in the memory region for this malloc heap which
/// represents the end of memory in use. Returns 0 if map file was closed.
void *TMapFile::GetBreakval() const
{
if (!fMmallocDesc) return 0;
return (void *)((struct mdesc *)fMmallocDesc)->breakval;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// Create a memory mapped file. /// Create a memory mapped file.
...@@ -1183,3 +1194,22 @@ void TMapFile::operator delete(void *ptr) ...@@ -1183,3 +1194,22 @@ void TMapFile::operator delete(void *ptr)
TObject::operator delete(ptr); TObject::operator delete(ptr);
} }
////////////////////////////////////////////////////////////////////////////////
TMapFile *TMapFile::WhichMapFile(void *addr)
{
if (!gROOT || !gROOT->GetListOfMappedFiles()) return 0;
TObjLink *lnk = ((TList *)gROOT->GetListOfMappedFiles())->LastLink();
while (lnk) {
TMapFile *mf = (TMapFile*)lnk->GetObject();
if (!mf) return 0;
if ((ULong_t)addr >= mf->fBaseAddr + mf->fOffset &&
(ULong_t)addr < (ULong_t)mf->GetBreakval() + mf->fOffset)
return mf;
lnk = lnk->Prev();
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment