Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMapFile.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Fons Rademakers 08/07/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11#ifdef WIN32
12#pragma optimize("",off)
13#endif
14
15/**
16\class TMapFile
17\ingroup IO
18
19This class implements a shared memory region mapped to a file.
20Objects can be placed into this shared memory area using the Add()
21member function. To actually place a copy of the object is shared
22memory call Update() also whenever the mapped object(s) change(s)
23call Update() to put a fresh copy in the shared memory. This extra
24step is necessary since it is not possible to share objects with
25virtual pointers between processes (the vtbl ptr points to the
26originators unique address space and can not be used by the
27consumer process(es)). Consumer processes can map the memory region
28from this file and access the objects stored in it via the Get()
29method (which returns a copy of the object stored in the shared
30memory with correct vtbl ptr set). Only objects of classes with a
31Streamer() member function defined can be shared.
32
33I know the current implementation is not ideal (you need to copy to
34and from the shared memory file) but the main problem is with the
35class' virtual_table pointer. This pointer points to a table unique
36for every process. Therefore, different options are:
37 -# One could allocate an object directly in shared memory in the
38 producer, but the consumer still has to copy the object from
39 shared memory into a local object which has the correct vtbl
40 pointer for that process (copy ctor's can be used for creating
41 the local copy).
42 -# Another possibility is to only allow objects without virtual
43 functions in shared memory (like simple C structs), or to
44 forbid (how?) the consumer from calling any virtual functions
45 of the objects in shared memory.
46 -# A last option is to copy the object internals to shared memory
47 and copy them again from there. This is what is done in the
48 TMapFile (using the object Streamer() to make a deep copy).
49
50Option 1) saves one copy, but requires solid copy ctor's (along the
51full inheritance chain) to rebuild the object in the consumer. Most
52classes don't provide these copy ctor's, especially not when objects
53contain collections, etc. 2) is too limiting or dangerous (calling
54accidentally a virtual function will segv). So since we have a
55robust Streamer mechanism I opted for 3).
56**/
57
58
59#ifdef WIN32
60# include <windows.h>
61# include <process.h>
62# ifdef GetObject
63# undef GetObject
64# endif
65# define HAVE_SEMOP
66
67# ifdef CreateSemaphore
68# undef CreateSemaphore
69# endif
70
71# ifdef AcquireSemaphore
72# undef AcquireSemaphore;
73# endif
74
75# ifdef ReleaseSemaphore
76# undef ReleaseSemaphore
77# endif
78
79# ifdef DeleteSemaphore
80# undef DeleteSemaphore
81# endif
82
83#else
84# define INVALID_HANDLE_VALUE -1
85#endif
86
87#include <fcntl.h>
88#include <errno.h>
89
90#include "TMapFile.h"
91#include "TKeyMapFile.h"
92#include "TDirectoryFile.h"
93#include "TBrowser.h"
94#include "TStorage.h"
95#include "TString.h"
96#include "TSystem.h"
97#include "TClass.h"
98#include "TROOT.h"
99#include "TBufferFile.h"
100#include "TVirtualMutex.h"
101#include "mmprivate.h"
102
103#include <cmath>
104
105#if defined(R__UNIX) && !defined(R__WINGCC)
106#define HAVE_SEMOP
107#include <sys/types.h>
108#include <sys/ipc.h>
109#include <sys/sem.h>
110#if !defined(WIN32) && !defined(R__MACOSX)
111union semun {
112 int val; // value for SETVAL
113 struct semid_ds *buf; // buffer for IPC_STAT & IPC_SET
114 ushort *array; // array for GETALL & SETALL
115};
116#endif
117#if defined(R__LINUX) || defined(R__LYNXOS) || defined(R__HURD)
118# define SEM_A 0200 // alter permission
119# define SEM_R 0400 // read permission
120#endif
121#endif
122
123
126
127//void *ROOT::Internal::gMmallocDesc = 0; //is initialized in TStorage.cxx
128
129
130namespace {
131////////////////////////////////////////////////////////////////////////////////
132/// Delete memory and return true if memory belongs to a TMapFile.
133 static bool FreeIfTMapFile(void* ptr) {
134 if (TMapFile *mf = TMapFile::WhichMapFile(ptr)) {
135 if (mf->IsWritable())
136 ::mfree(mf->GetMmallocDesc(), ptr);
137 return true;
138 }
139 return false;
140 }
141
142/// Return the memory mapped start location corresponding to the user pointer
143/// if any. Return `nullptr` otherwise.
144 static void *GetMapFileMallocDesc(void *userptr)
145 {
146 if (TMapFile *mf = TMapFile::WhichMapFile(userptr))
147 {
148 return mf->GetMmallocDesc();
149 }
150 return nullptr;
151 }
152}
153
154
155////////////////////////////////////////////////////////////////////////////////
156/// Set ROOT::Internal::gFreeIfTMapFile on library load.
157
160 ROOT::Internal::gFreeIfTMapFile = FreeIfTMapFile;
161 ROOT::Internal::gGetMapFileMallocDesc = GetMapFileMallocDesc;
162 }
166 }
168
169
170////////////////////////////////////////////////////////////////////////////////
171//// Constructor.
172
173TMapRec::TMapRec(const char *name, const TObject *obj, Int_t size, void *buf)
174{
175 fName = StrDup(name);
176 fClassName = 0;
177 fObject = (TObject*)obj;
178 fBuffer = buf;
179 fBufSize = size;
180 fNext = 0;
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Destructor.
185
187{
188 delete [] fName;
189 delete [] fClassName;
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// This method returns a pointer to the original object.
194
195/// NOTE: this pointer is only valid in the process that produces the shared
196/// memory file. In a consumer process this pointer is illegal! Be careful.
197
199{
200 return fObject;
201}
202
203
204
205
207
208////////////////////////////////////////////////////////////////////////////////
209/// Default ctor. Does not much except setting some basic values.
210
212{
213 fFd = -1;
214 fVersion = 0;
215 fName = nullptr;
216 fTitle = nullptr;
217 fOption = nullptr;
218 fMmallocDesc = nullptr;
219 fBaseAddr = 0;
220 fSize = 0;
221 fFirst = nullptr;
222 fLast = nullptr;
223 fOffset = 0;
224 fDirectory = nullptr;
225 fBrowseList = nullptr;
227 fSemaphore = -1;
228 fhSemaphore = 0;
229 fGetting = nullptr;
230 fWritten = 0;
231 fSumBuffer = 0;
232 fSum2Buffer = 0;
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Create a memory mapped file.
237///
238/// This opens a file (to which the
239/// memory will be mapped) and attaches a memory region to it.
240/// Option can be either: "NEW", "CREATE", "RECREATE", "UPDATE" or
241/// "READ" (see TFile). The default open mode is "READ". The size
242/// argument specifies the maximum size of shared memory file in bytes.
243/// This protected ctor is called via the static Create() method.
244
245TMapFile::TMapFile(const char *name, const char *title, Option_t *option,
246 Int_t size, TMapFile *&newMapFile)
247{
248#ifndef WIN32
249 fFd = -1;
250 fSemaphore = -1;
251 fhSemaphore = 0;
252#else
255#endif
256 fMmallocDesc = nullptr;
257 fSize = size;
258 fFirst = 0;
259 fOffset = 0;
260 fVersion = gROOT->GetVersionInt();
261 fTitle = StrDup(title);
263 fDirectory = nullptr;
264 fBrowseList = nullptr;
265 fGetting = nullptr;
266 fWritten = 0;
267 fSumBuffer = 0;
268 fSum2Buffer = 0;
269
270 char *cleanup = nullptr;
272 Bool_t recreate, update, read;
273
274 {
275 TString opt = option;
276
277 if (!opt.CompareTo("NEW", TString::kIgnoreCase) ||
278 !opt.CompareTo("CREATE", TString::kIgnoreCase))
279 create = kTRUE;
280 recreate = opt.CompareTo("RECREATE", TString::kIgnoreCase)
281 ? kFALSE : kTRUE;
282 update = opt.CompareTo("UPDATE", TString::kIgnoreCase)
283 ? kFALSE : kTRUE;
284 read = opt.CompareTo("READ", TString::kIgnoreCase)
285 ? kFALSE : kTRUE;
286 if (!create && !recreate && !update && !read) {
287 read = kTRUE;
288 delete [] fOption;
289 fOption = StrDup("READ");
290 }
291 }
292
293 const char *fname;
294 if ((fName = gSystem->ExpandPathName(name))) {
295 fname = fName;
296 } else {
297 Error("TMapFile", "error expanding path %s", name);
298 goto zombie;
299 }
300
301 if (recreate) {
302 if (!gSystem->AccessPathName(fname, kFileExists))
303 gSystem->Unlink(fname);
304 recreate = kFALSE;
305 create = kTRUE;
306 delete [] fOption;
307 fOption = StrDup("CREATE");
308 }
309 if (create && !gSystem->AccessPathName(fname, kFileExists)) {
310 Error("TMapFile", "file %s already exists", fname);
311 goto zombie;
312 }
313 if (update) {
314 if (gSystem->AccessPathName(fname, kFileExists)) {
315 update = kFALSE;
316 create = kTRUE;
317 }
319 Error("TMapFile", "no write permission, could not open file %s", fname);
320 goto zombie;
321 }
322 }
323 if (read) {
324 if (gSystem->AccessPathName(fname, kFileExists)) {
325 Error("TMapFile", "file %s does not exist", fname);
326 goto zombie;
327 }
329 Error("TMapFile", "no read permission, could not open file %s", fname);
330 goto zombie;
331 }
332 }
333
334 // Open file to which memory will be mapped
335 if (create || update) {
336#ifndef WIN32
337 fFd = open(fname, O_RDWR | O_CREAT, 0644);
338#else
339 fFd = (Longptr_t) CreateFile(fname, // pointer to name of the file
340 GENERIC_WRITE | GENERIC_READ, // access (read-write) mode
341 FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode
342 NULL, // pointer to security attributes
343 OPEN_ALWAYS, // how to create
344 FILE_ATTRIBUTE_TEMPORARY, // file attributes
345 (HANDLE) NULL); // handle to file with attributes to copy
346#endif
348 SysError("TMapFile", "file %s can not be opened", fname);
349 goto zombie;
350 }
352 } else {
353#ifndef WIN32
354 fFd = open(fname, O_RDONLY);
355#else
356 fFd = (Longptr_t) CreateFile(fname, // pointer to name of the file
357 GENERIC_READ, // access (read-write) mode
358 FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode
359 NULL, // pointer to security attributes
360 OPEN_EXISTING, // how to create
361 FILE_ATTRIBUTE_TEMPORARY, // file attributes
362 (HANDLE) NULL); // handle to file with attributes to copy
363#endif
365 SysError("TMapFile", "file %s can not be opened for reading", fname);
366 goto zombie;
367 }
369 }
370
371 // Attach memory region to file.
372 void *mapto;
373 TMapFile *mapfil;
374
375 if (((mapto = MapToAddress()) == (void *)-1) ||
376#ifndef WIN32
377 ((fMmallocDesc = mmalloc_attach(fFd, mapto, fSize)) == 0)) {
378#else
379 ((fMmallocDesc = mmalloc_attach((HANDLE) fFd, mapto, fSize)) == 0)) {
380#endif
381
382 if (mapto == (void *)-1) {
383 Error("TMapFile", "no memory mapped file capability available\n"
384 "Use rootn.exe or link application against \"-lNew\"");
385 } else {
386 if (fMmallocDesc == 0 && fWritable)
387 Error("TMapFile", "mapped file not in mmalloc format or\n"
388 "already open in RW mode by another process");
389 if (fMmallocDesc == 0 && !fWritable)
390 Error("TMapFile", "mapped file not in mmalloc format");
391 }
392#ifndef WIN32
393 close(fFd);
394#else
395 CloseHandle((HANDLE) fFd);
396#endif
397 fFd = -1;
398 if (create)
399 gSystem->Unlink(fname);
400 goto zombie;
401
402 } else if ((mapfil = (TMapFile *) mmalloc_getkey(fMmallocDesc, 0)) != 0) {
403
404 // File contains mmalloc heap. If we are in write mode and mapped
405 // file already connected in write mode switch to read-only mode.
406 // Check if ROOT versions are compatible.
407 // If so update mapped version of TMapFile to reflect current
408 // situation (only if not opened in READ mode).
409 if (mapfil->fVersion != fVersion) {
410 Error("TMapFile", "map file %s (%d) incompatible with current ROOT version (%d)",
411 fname, mapfil->fVersion, fVersion);
412 mmalloc_detach(fMmallocDesc);
413#ifndef WIN32
414 close(fFd);
415#else
416 CloseHandle((HANDLE) fFd);
417#endif
418 fFd = -1;
419 fMmallocDesc = 0;
420 goto zombie;
421 }
422
423 if (mapfil->fWritable && fWritable) {
424 Warning("TMapFile", "map file already open in write mode, opening in read-only mode");
426 }
427
428 fBaseAddr = mapfil->fBaseAddr;
429 fSize = mapfil->fSize;
430
431 if (fWritable) {
432 // create new TMapFile object in mapped heap to get correct vtbl ptr
435 TMapFile *mf = new TMapFile(*mapfil);
436 mf->fFd = fFd;
437 mf->fWritable = kTRUE;
438 cleanup = mf->fOption;
439 mf->fOption = StrDup(fOption);
441#ifdef WIN32
443#endif
444 mmalloc_setkey(fMmallocDesc, 0, mf);
446 mapfil = mf;
447 } else {
448 ROOT::Internal::gMmallocDesc = 0; // make sure we are in sbrk heap
449 fOffset = ((struct mdesc *) fMmallocDesc)->offset;
450 TMapFile *mf = new TMapFile(*mapfil, fOffset);
451 delete [] mf->fOption;
452 mf->fFd = fFd;
453 mf->fOption = StrDup("READ");
455 mf->fWritable = kFALSE;
456 mapfil = mf;
457 }
458
459 // store shadow mapfile (it contains the real fFd in case map
460 // is not writable)
461 fVersion = -1; // make this the shadow map file
463 gROOT->GetListOfMappedFiles()->AddLast(this);
464
465 } else {
466
467 // New file. If the file is writable create a new copy of the
468 // TMapFile which will now be allocated on the memory mapped heap.
469 if (!fWritable) {
470 Error("TMapFile", "map file is not writable");
471 mmalloc_detach(fMmallocDesc);
472#ifndef WIN32
473 close(fFd);
474#else
475 CloseHandle((HANDLE) fFd);
476#endif
477 fFd = -1;
478 fMmallocDesc = 0;
479 goto zombie;
480 }
481
482 fBaseAddr = (ULongptr_t)((struct mdesc *) fMmallocDesc)->base;
483
485
487
488 mapfil = new TMapFile(*this);
489 mmalloc_setkey(fMmallocDesc, 0, mapfil);
490
492
493 // store shadow mapfile
494 fVersion = -1; // make this the shadow map file
496 gROOT->GetListOfMappedFiles()->AddLast(this);
497
498 }
499
500 mapfil->InitDirectory();
501 {
503 gROOT->GetListOfMappedFiles()->AddFirst(mapfil);
504 }
505
506 if (cleanup) delete [] cleanup;
507
508 newMapFile = mapfil;
509
510 return;
511
512zombie:
513 // error in file opening occured, make this object a zombie
514 MakeZombie();
515 newMapFile = this;
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Private copy ctor.
521///
522/// Used by the ctor to create a new version
523/// of TMapFile in the memory mapped heap. It's main purpose is to
524/// correctly create the string data members.
525
527{
528 fFd = f.fFd;
529 fVersion = f.fVersion;
530 fName = StrDup((char *)((Longptr_t)f.fName + offset));
531 fTitle = StrDup((char *)((Longptr_t)f.fTitle + offset));
532 fOption = StrDup((char *)((Longptr_t)f.fOption + offset));
533 fMmallocDesc = f.fMmallocDesc;
534 fBaseAddr = f.fBaseAddr;
535 fSize = f.fSize;
536 fFirst = f.fFirst;
537 fLast = f.fLast;
538 fWritable = f.fWritable;
539 fSemaphore = f.fSemaphore;
540 fOffset = offset;
541 fDirectory = nullptr;
542 fBrowseList = nullptr;
543 fGetting = nullptr;
544 fWritten = f.fWritten;
545 fSumBuffer = f.fSumBuffer;
546 fSum2Buffer = f.fSum2Buffer;
547#ifdef WIN32
549#else
550 fhSemaphore = f.fhSemaphore;
551#endif
552}
553
554////////////////////////////////////////////////////////////////////////////////
555/// TMapFiles may not be deleted, since we want to keep the complete
556/// TMapFile object in the mapped file for later re-use. To enforce this
557/// the delete operator has been made private. Use Close() to properly
558/// terminate a TMapFile (also done via the TROOT dtor).
559
561{
563 delete fDirectory; fDirectory = nullptr;
564 if (fBrowseList) {
566 delete fBrowseList;
567 fBrowseList = nullptr;
568 }
569
570
571 // if shadow map file we are done here
572 if (fVersion == -1)
573 return;
574
575 // Writable mapfile is allocated in mapped memory. This object should
576 // not be deleted by ::operator delete(), because it is needed if we
577 // want to connect later to the file again.
578 if (fWritable)
580
581 Close("dtor");
582
583 // Tell TMapFile::operator delete which memory address to detach
584 // The detaching must be done after the whole object has been tear down
585 // (including base classes).
587
588 delete [] fName; fName = nullptr;
589 delete [] fOption; fOption = nullptr;
590 delete [] fTitle; fTitle = nullptr;
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// Create the directory associated to this mapfile
595
597{
598 gDirectory = nullptr;
602 fDirectory->Build();
603 fDirectory->SetMother(this);
605}
606
607////////////////////////////////////////////////////////////////////////////////
608/// Add an object to the list of objects to be stored in shared memory.
609/// To place the object actually into shared memory call Update().
610
611void TMapFile::Add(const TObject *obj, const char *name)
612{
613 if (!fWritable || !fMmallocDesc) return;
614
615 Bool_t lock = fGetting != obj ? kTRUE : kFALSE;
616
617 if (lock)
619
620 const char *n;
621 if (name && *name)
622 n = name;
623 else
624 n = obj->GetName();
625
626 if (Remove(n, kFALSE)) {
627 //Warning("Add", "replaced object with same name %s", n);
628 }
629
631 TMapRec *mr = new TMapRec(n, obj, 0, 0);
633
634 if (!fFirst) {
635 fFirst = mr;
636 fLast = mr;
637 } else {
638 fLast->fNext = mr;
639 fLast = mr;
640 }
641
642
643 if (lock)
645}
646
647namespace {
648 // Wrapper around TStorage::ReAlloc to update the signature.
649 char *MemMapAllocFunc(char *oldptr, size_t newsize, size_t oldsize)
650 {
651 return reinterpret_cast<char*>(TStorage::ReAlloc(oldptr, newsize, oldsize));
652 }
653}
654
655////////////////////////////////////////////////////////////////////////////////
656/// Update an object (or all objects, if obj == 0) in shared memory.
657
659{
660 if (!fWritable || !fMmallocDesc) return;
661
663
664 Bool_t all = (obj == 0) ? kTRUE : kFALSE;
665
666 TMapRec *mr = fFirst;
667 while (mr) {
668 if (all || mr->fObject == obj) {
669 TBufferFile *b;
670 if (!mr->fBufSize) {
671 const char *cname = mr->fObject->ClassName();
672 mr->fBufSize = GetBestBuffer();
673
675 mr->fBuffer = new char[mr->fBufSize];
676 mr->fClassName = StrDup(cname);
678 }
679 b = new TBufferFile(TBuffer::kWrite, mr->fBufSize, mr->fBuffer, kFALSE, MemMapAllocFunc);
680 b->MapObject(mr->fObject); //register obj in map to handle self reference
681 mr->fObject->Streamer(*b);
682 mr->fBufSize = b->BufferSize() + 8; // extra space at end of buffer (used for free block count) there on
683 mr->fBuffer = b->Buffer();
684 SumBuffer(b->Length());
685 b->DetachBuffer();
686 delete b;
687 }
688 mr = mr->fNext;
689 }
690
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// Remove object from shared memory.
696///
697/// Returns pointer to removed object if successful, 0 otherwise.
698
700{
701 if (!fWritable || !fMmallocDesc) return 0;
702
703 if (lock)
705
706 TObject *retObj = 0;
707 TMapRec *prev = 0, *mr = fFirst;
708 while (mr) {
709 if (mr->fObject == obj) {
710 if (mr == fFirst) {
711 fFirst = mr->fNext;
712 if (mr == fLast)
713 fLast = 0;
714 } else {
715 prev->fNext = mr->fNext;
716 if (mr == fLast)
717 fLast = prev;
718 }
719 retObj = obj;
720 delete mr;
721 break;
722 }
723 prev = mr;
724 mr = mr->fNext;
725 }
726
727 if (lock)
729
730 return retObj;
731}
732
733////////////////////////////////////////////////////////////////////////////////
734/// Remove object by name from shared memory.
735///
736/// Returns pointer to removed object if successful, 0 otherwise.
737
739{
740 if (!fWritable || !fMmallocDesc) return 0;
741
742 if (lock)
744
745 TObject *retObj = 0;
746 TMapRec *prev = 0, *mr = fFirst;
747 while (mr) {
748 if (!strcmp(mr->fName, name)) {
749 if (mr == fFirst) {
750 fFirst = mr->fNext;
751 if (mr == fLast)
752 fLast = 0;
753 } else {
754 prev->fNext = mr->fNext;
755 if (mr == fLast)
756 fLast = prev;
757 }
758 retObj = mr->fObject;
759 delete mr;
760 break;
761 }
762 prev = mr;
763 mr = mr->fNext;
764 }
765
766 if (lock)
768
769 return retObj;
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Remove all objects from shared memory.
774
776{
777 if (!fWritable || !fMmallocDesc) return;
778
780
781 TMapRec *mr = fFirst;
782 while (mr) {
783 TMapRec *t = mr;
784 mr = mr->fNext;
785 delete t;
786 }
787 fFirst = fLast = 0;
788
790}
791
792////////////////////////////////////////////////////////////////////////////////
793/// Return pointer to object retrieved from shared memory.
794///
795/// The object must
796/// be deleted after use. If delObj is a pointer to a previously allocated
797/// object it will be deleted. Returns 0 in case object with the given
798/// name does not exist.
799
800TObject *TMapFile::Get(const char *name, TObject *delObj)
801{
802 if (!fMmallocDesc) return 0;
803
805
806 delete delObj;
807
808 TObject *obj = 0;
809 TMapRec *mr = GetFirst();
810 while (OrgAddress(mr)) {
811 if (!strcmp(mr->GetName(fOffset), name)) {
812 if (!mr->fBufSize) goto release;
814 if (!cl) {
815 Error("Get", "unknown class %s", mr->GetClassName(fOffset));
816 goto release;
817 }
818
819 obj = (TObject *)cl->New();
820 if (!obj) {
821 Error("Get", "cannot create new object of class %s", mr->GetClassName(fOffset));
822 goto release;
823 }
824
825 fGetting = obj;
827 b->MapObject(obj); //register obj in map to handle self reference
828 obj->Streamer(*b);
829 b->DetachBuffer();
830 delete b;
831 fGetting = 0;
832 goto release;
833 }
834 mr = mr->GetNext(fOffset);
835 }
836
837release:
839
840 return obj;
841}
842
843////////////////////////////////////////////////////////////////////////////////
844/// Create semaphore used for synchronizing access to shared memory.
845
846#ifndef WIN32
848#else
849void TMapFile::CreateSemaphore(int pid)
850#endif
851{
852#ifdef HAVE_SEMOP
853#ifndef WIN32
854 // create semaphore to synchronize access (should use read/write lock)
855 fSemaphore = semget(IPC_PRIVATE, 1, SEM_R|SEM_A|(SEM_R>>3)|(SEM_A>>3)|
856 (SEM_R>>6)|(SEM_A>>6));
857
858 // set semaphore to 1
859 if (fSemaphore != -1) {
860 union semun set;
861 set.val = 1;
862 semctl(fSemaphore, 0, SETVAL, set);
863 }
864#else
865 char buffer[] ="ROOT_Semaphore_xxxxxxxx";
866 int lbuf = strlen(buffer);
867 if (!pid) fSemaphore = getpid();
868 fhSemaphore = (ULongptr_t)CreateMutex(NULL,FALSE,itoa(fSemaphore,&buffer[lbuf-8],16));
869 if (fhSemaphore == 0) fSemaphore = (Longptr_t)INVALID_HANDLE_VALUE;
870#endif
871#endif
872}
873
874////////////////////////////////////////////////////////////////////////////////
875/// Delete the semaphore.
876
878{
879#ifdef HAVE_SEMOP
880 // remove semaphore
881#ifndef WIN32
882 if (fSemaphore != -1) {
883 int semid = fSemaphore;
884 fSemaphore = -1;
885 union semun set;
886 set.val = 0;
887 semctl(semid, 0, IPC_RMID, set);
888 }
889#else
891 CloseHandle((HANDLE)fhSemaphore);
892 fhSemaphore = 0;
894 }
895#endif
896#endif
897}
898
899////////////////////////////////////////////////////////////////////////////////
900/// Acquire semaphore. Returns 0 if OK, -1 on error.
901
903{
904#ifdef HAVE_SEMOP
905#ifndef WIN32
906 if (fSemaphore != -1) {
907 struct sembuf buf = { 0, -1, SEM_UNDO };
908 int intr = 0;
909again:
910 if (semop(fSemaphore, &buf, 1) == -1) {
911#if defined(R__FBSD) || defined(R__OBSD)
912 if (TSystem::GetErrno() == EINVAL)
913#else
914 if (TSystem::GetErrno() == EIDRM)
915#endif
916 fSemaphore = -1;
917#if !defined(R__FBSD)
918 if (TSystem::GetErrno() == EINTR) {
919 if (intr > 2)
920 return -1;
922 intr++;
923 goto again;
924 }
925#endif
926 }
927 }
928#else
929 // Enter Critical section to "write" lock
931 WaitForSingleObject((HANDLE)fhSemaphore,INFINITE);
932#endif
933#endif
934
935 // file might have grown, update mapping on reader to new size
936 if (!fWritable && fMmallocDesc) {
937 if (mmalloc_update_mapping(fMmallocDesc) == -1)
938 Error("AcquireSemaphore", "cannot update mapping");
939 }
940
941 return 0;
942}
943
944////////////////////////////////////////////////////////////////////////////////
945/// Release semaphore. Returns 0 if OK, -1 on error.
946
948{
949#ifdef HAVE_SEMOP
950#ifndef WIN32
951 if (fSemaphore != -1) {
952 struct sembuf buf = { 0, 1, SEM_UNDO };
953 if (semop(fSemaphore, &buf, 1) == -1) {
954#if defined(R__FBSD) || defined(R__OBSD)
955 if (TSystem::GetErrno() == EINVAL)
956#else
957 if (TSystem::GetErrno() == EIDRM)
958#endif
959 fSemaphore = -1;
960 }
961 }
962#else
964 ReleaseMutex((HANDLE)fhSemaphore);
965#endif
966#endif
967 return 0;
968}
969
970////////////////////////////////////////////////////////////////////////////////
971/// Close a mapped file.
972///
973/// First detach mapped memory then close file.
974/// No member functions of a TMapFile that was opened in write mode
975/// may be called after Close() (this includes, of course, "delete" which
976/// would call the dtors). The option="dtor" is only used when called
977/// via the ~TMapFile.
978
980{
981 if (!fMmallocDesc) return;
982
983 TMapFile *shadow = FindShadowMapFile();
984 if (!shadow) {
985 Error("Close", "shadow map == 0, should never happen!");
986 return;
987 }
988
989 {
991 gROOT->GetListOfMappedFiles()->Remove(shadow);
992 gROOT->GetListOfMappedFiles()->Remove(this);
993 }
994
995 if (shadow->fWritable) {
998 }
999
1000 if (fMmallocDesc) {
1001 if (strcmp(option, "dtor"))
1002 mmalloc_detach(fMmallocDesc);
1003
1004 // If writable cannot access fMmallocDesc anymore since
1005 // it points to the just unmapped memory region. Any further
1006 // access to this TMapFile will cause a crash.
1007 if (!shadow->fWritable)
1008 fMmallocDesc = 0;
1009 }
1010
1011 if (shadow->fFd != -1)
1012#ifndef WIN32
1013 close(shadow->fFd);
1014#else
1015 CloseHandle((HANDLE)shadow->fFd);
1016#endif
1017
1018 delete shadow;
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Returns shadow map file.
1023
1025{
1027 TObjLink *lnk = ((TList *)gROOT->GetListOfMappedFiles())->LastLink();
1028 while (lnk) {
1029 TMapFile *mf = (TMapFile*)lnk->GetObject();
1030 if (mf->fVersion == -1 && fBaseAddr == mf->fBaseAddr && fSize == mf->fSize)
1031 return mf;
1032 lnk = lnk->Prev();
1033 }
1034 return 0;
1035}
1036
1037////////////////////////////////////////////////////////////////////////////////
1038/// Print some info about the mapped file.
1039
1041{
1042 Printf("Memory mapped file: %s", fName);
1043 Printf("Title: %s", fTitle);
1044 if (fMmallocDesc) {
1045 Printf("Option: %s", fOption);
1046 size_t size = (size_t)((struct mdesc *)fMmallocDesc)->top - fBaseAddr;
1047 Printf("Mapped Memory region: 0x%zx - 0x%zx (%.2f MB)", (size_t)fBaseAddr, (size_t)fBaseAddr + size,
1048 (float)size/1048576);
1049 Printf("Current breakval: 0x%zx", (size_t)GetBreakval());
1050 } else
1051 Printf("Option: file closed");
1052}
1053
1054////////////////////////////////////////////////////////////////////////////////
1055/// Returns kTRUE in case object is a folder (i.e. contains browsable lists).
1056
1058{
1059 if (fMmallocDesc && fVersion > 0) return kTRUE;
1060 return kFALSE;
1061}
1062
1063////////////////////////////////////////////////////////////////////////////////
1064/// Browse contents of TMapFile.
1065
1067{
1068 if (b && fMmallocDesc) {
1069
1071
1072 TMapRec *mr = GetFirst();
1073 TKeyMapFile *keymap;
1074 if (!fBrowseList) fBrowseList = new TList();
1075 while (OrgAddress(mr)) {
1077 if (!keymap) {
1078 keymap = new TKeyMapFile(mr->GetName(fOffset),mr->GetClassName(fOffset),this);
1079 fBrowseList->Add(keymap);
1080 }
1081 b->Add(keymap, keymap->GetName());
1082 mr = mr->GetNext(fOffset);
1083 }
1084
1086
1087 }
1088}
1089
1090////////////////////////////////////////////////////////////////////////////////
1091/// Cd to associated directory.
1092
1093Bool_t TMapFile::cd(const char *path)
1094{
1095 if (fDirectory)
1096 return fDirectory->cd(path);
1097 return kFALSE;
1098}
1099
1100////////////////////////////////////////////////////////////////////////////////
1101/// List contents of TMapFile.
1102
1104{
1105 if (fMmallocDesc) {
1106
1107 ((TMapFile*)this)->AcquireSemaphore();
1108
1109 Printf("%-20s %-20s %-10s", "Object", "Class", "Size");
1110 if (!fFirst)
1111 Printf("*** no objects stored in memory mapped file ***");
1112
1113 TMapRec *mr = GetFirst();
1114 while (OrgAddress(mr)) {
1115 Printf("%-20s %-20s %-10d", mr->GetName(fOffset),
1116 mr->GetClassName(fOffset), mr->fBufSize);
1117 mr = mr->GetNext(fOffset);
1118 }
1119
1120 ((TMapFile*)this)->ReleaseSemaphore();
1121
1122 }
1123}
1124
1125////////////////////////////////////////////////////////////////////////////////
1126/// Increment statistics for buffer sizes of objects in this file.
1127
1129{
1130 fWritten++;
1131 fSumBuffer += bufsize;
1132 fSum2Buffer += bufsize*bufsize;
1133}
1134
1135////////////////////////////////////////////////////////////////////////////////
1136/// Return the best buffer size for objects in this file.
1137///
1138/// The best buffer size is estimated based on the current mean value
1139/// and standard deviation of all objects written so far to this file.
1140/// Returns mean value + one standard deviation.
1141
1143{
1144 if (!fWritten) return TBuffer::kMinimalSize;
1146 Double_t rms2 = TMath::Abs(fSum2Buffer/fSumBuffer - mean*mean);
1147 return (Int_t)(mean + std::sqrt(rms2));
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Return the current location in the memory region for this malloc heap which
1152/// represents the end of memory in use. Returns 0 if map file was closed.
1153
1155{
1156 if (!fMmallocDesc) return 0;
1157 return (void *)((struct mdesc *)fMmallocDesc)->breakval;
1158}
1159
1160////////////////////////////////////////////////////////////////////////////////
1161/// Create a memory mapped file.
1162///
1163/// This opens a file (to which the
1164/// memory will be mapped) and attaches a memory region to it.
1165/// Option can be either: "NEW", "CREATE", "RECREATE", "UPDATE"
1166/// or "READ" (see TFile). The default open mode is "READ". The size
1167/// argument specifies the maximum size of shared memory file in bytes.
1168/// TMapFile's can only be created via this method. Create() enforces that
1169/// a TMapFile is always on the memory mapped heap (when "NEW", "CREATE"
1170/// or "RECREATE" are used).
1171
1173 const char *title)
1174{
1175 TMapFile *newMapFile;
1176 new TMapFile(name, title, option, size, newMapFile);
1177
1178 return newMapFile;
1179}
1180
1181////////////////////////////////////////////////////////////////////////////////
1182/// Set preferred map address.
1183///
1184/// Find out preferred map address as follows:
1185/// -# Run consumer program to find the preferred map address. Remember begin of mapped region, i.e. 0x40b4c000
1186/// ~~~{.cpp}
1187/// $ root
1188/// root [0] m = TMapFile::Create("dummy.map", "recreate", 10000000);
1189/// root [1] m.Print()
1190/// Memory mapped file: dummy.map
1191/// Title:
1192/// Option: CREATE
1193/// Mapped Memory region: 0x40b4c000 - 0x40d95f00 (2.29 MB)
1194/// Current breakval: 0x40b53000
1195/// root [2] .q
1196/// $ rm dummy.map
1197/// ~~~
1198/// -# Add to producer program, just before creating the TMapFile:
1199/// TMapFile::SetMapAddress(0x40b4c000);
1200///
1201/// Repeat this if more than one map file is being used.
1202/// The above procedure allow programs using, e.g., different number of
1203/// shared libraries (that cause the default mapping address to be
1204/// different) to create shared memory regions in the same location
1205/// without overwriting a shared library. The above assumes the consumer
1206/// program is larger (i.e. has more shared memory occupied) than the
1207/// producer. If this is not true inverse the procedure.
1208
1210{
1211 fgMapAddress = addr;
1212}
1213
1214////////////////////////////////////////////////////////////////////////////////
1215/// Return the base address at which we would like the next TMapFile's
1216/// mapped data to start.
1217///
1218/// For now, we let the system decide (start address 0). There are
1219/// a lot of issues to deal with here to make this work reasonably,
1220/// including:
1221/// - Avoid memory collisions with existing mapped address spaces
1222/// - Reclaim address spaces when their mmalloc heaps are unmapped
1223/// - When mmalloc heaps are shared between processes they have to be
1224/// mapped at the same addresses in each
1225///
1226/// Once created, a mmalloc heap that is to be mapped back in must be
1227/// mapped at the original address. I.e. each TMapFile will expect
1228/// to be remapped at it's original address. This becomes a problem if
1229/// the desired address is already in use.
1230
1232{
1233#ifdef R__HAVE_MMAP
1235 return (void *)fgMapAddress;
1236 else
1237 return (void *)-1;
1238#else
1239 return (void *)-1;
1240#endif
1241}
1242
1243////////////////////////////////////////////////////////////////////////////////
1244/// Need special "operator delete" in which we close the shared memory.
1245/// This has to be done after the dtor chain has been finished.
1246
1247void TMapFile::operator delete(void *ptr)
1248{
1249 mmalloc_detach(fgMmallocDesc);
1250 fgMmallocDesc = 0;
1251
1252 TObject::operator delete(ptr);
1253}
1254
1255////////////////////////////////////////////////////////////////////////////////
1256
1258{
1259 // Don't use gROOT so that this routine does not trigger TROOT's initialization
1260 // This is essential since this routine is called via operator delete
1261 // which is used during RegisterModule (i.e. during library loading, including the initial
1262 // start up). Using gROOT leads to recursive call to RegisterModule and initialization of
1263 // the interpreter in the middle of the execution of RegisterModule (i.e. undefined behavior).
1264 if (!ROOT::Internal::gROOTLocal || !ROOT::Internal::gROOTLocal->GetListOfMappedFiles())
1265 return 0;
1266
1267 TObjLink *lnk = ((TList *)ROOT::Internal::gROOTLocal->GetListOfMappedFiles())->LastLink();
1268 while (lnk) {
1269 TMapFile *mf = (TMapFile*)lnk->GetObject();
1270 if (!mf) return 0;
1271 if ((ULongptr_t)addr >= mf->fBaseAddr + mf->fOffset &&
1272 (ULongptr_t)addr < (ULongptr_t)mf->GetBreakval() + mf->fOffset)
1273 return mf;
1274 lnk = lnk->Prev();
1275 }
1276 return 0;
1277}
1278
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &adata, const RooArgSet &projDeps, RooAbsTestStatistic::Configuration const &cfg) override
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long Longptr_t
Definition RtypesCore.h:82
unsigned long ULongptr_t
Definition RtypesCore.h:83
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
#define gDirectory
Definition TDirectory.h:384
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
char name[80]
Definition TGX11.cxx:110
struct SetFreeIfTMapFile_t gSetFreeIfTMapFile
#define INVALID_HANDLE_VALUE
Definition TMapFile.cxx:84
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:407
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2481
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2535
@ kFileExists
Definition TSystem.h:44
@ kReadPermission
Definition TSystem.h:47
@ kWritePermission
Definition TSystem.h:46
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
#define R__LOCKGUARD(mutex)
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
@ kWrite
Definition TBuffer.h:73
@ kRead
Definition TBuffer.h:73
@ kMinimalSize
Definition TBuffer.h:78
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:4978
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2968
A ROOT file is structured in Directories (like a file system).
virtual void Build(TFile *motherFile=nullptr, TDirectory *motherDir=nullptr)
Definition TDirectory.h:186
virtual Bool_t cd()
Change current directory to "this" directory.
void SetName(const char *newname) override
Set the name for directory If the directory name is changed after the directory was written once,...
virtual void SetMother(TObject *mother)
Definition TDirectory.h:258
Utility class for browsing TMapFile objects.
Definition TKeyMapFile.h:20
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:578
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:470
This class implements a shared memory region mapped to a file.
Definition TMapFile.h:26
static TMapFile * WhichMapFile(void *addr)
void * GetBreakval() const
Return the current location in the memory region for this malloc heap which represents the end of mem...
Int_t fWritten
Number of objects written so far.
Definition TMapFile.h:48
static TMapFile * Create(const char *name, Option_t *option="READ", Int_t size=kDefaultMapSize, const char *title="")
Create a memory mapped file.
TMapRec * fLast
Last object in list of shared objects.
Definition TMapFile.h:40
Int_t fVersion
ROOT version (or -1 for shadow map file)
Definition TMapFile.h:32
Bool_t IsFolder() const override
Returns kTRUE in case object is a folder (i.e. contains browsable lists).
ULongptr_t fBaseAddr
Base address of mapped memory region.
Definition TMapFile.h:37
const char * GetName() const override
Returns name of object.
Definition TMapFile.h:94
void ls(Option_t *option="") const override
List contents of TMapFile.
TDirectory * fDirectory
Pointer to directory associated to this mapfile.
Definition TMapFile.h:42
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
const char * GetTitle() const override
Returns title of object.
Definition TMapFile.h:97
TObject * Get(const char *name, TObject *retObj=nullptr)
Return pointer to object retrieved from shared memory.
Definition TMapFile.cxx:800
void Print(Option_t *option="") const override
Print some info about the mapped file.
char * fTitle
Title of mapped file.
Definition TMapFile.h:34
void InitDirectory()
Create the directory associated to this mapfile.
Definition TMapFile.cxx:596
void RemoveAll()
Remove all objects from shared memory.
Definition TMapFile.cxx:775
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition TMapFile.h:50
Bool_t fWritable
TRUE if mapped file opened in RDWR mode.
Definition TMapFile.h:44
Longptr_t fOffset
Offset in bytes for region mapped by reader.
Definition TMapFile.h:41
void Close(Option_t *option="") override
Close a mapped file.
Definition TMapFile.cxx:979
void * OrgAddress(void *addr) const
Definition TMapFile.h:102
Bool_t cd(const char *path=nullptr)
Cd to associated directory.
void DeleteSemaphore()
Delete the semaphore.
Definition TMapFile.cxx:877
Longptr_t fSemaphore
Modification semaphore (or getpid() for WIN32)
Definition TMapFile.h:45
TList * fBrowseList
List of KeyMapFile objects.
Definition TMapFile.h:43
TMapRec * fFirst
List of streamed objects is shared memory.
Definition TMapFile.h:39
~TMapFile() override
TMapFiles may not be deleted, since we want to keep the complete TMapFile object in the mapped file f...
Definition TMapFile.cxx:560
ULongptr_t fhSemaphore
HANDLE of WIN32 Mutex object to implement semaphore.
Definition TMapFile.h:46
static void * MapToAddress()
Return the base address at which we would like the next TMapFile's mapped data to start.
void Update(TObject *obj=nullptr)
Update an object (or all objects, if obj == 0) in shared memory.
Definition TMapFile.cxx:658
TObject * fGetting
Don't deadlock in update mode, when from Get() Add() is called.
Definition TMapFile.h:47
TMapFile * FindShadowMapFile()
Returns shadow map file.
void * fMmallocDesc
Pointer to mmalloc descriptor.
Definition TMapFile.h:36
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition TMapFile.h:49
static void * fgMmallocDesc
Used in Close() and operator delete()
Definition TMapFile.h:53
void CreateSemaphore(Int_t pid=0)
Create semaphore used for synchronizing access to shared memory.
Definition TMapFile.cxx:847
Longptr_t fFd
Descriptor of mapped file.
Definition TMapFile.h:31
Int_t fSize
Original start size of memory mapped region.
Definition TMapFile.h:38
TObject * Remove(TObject *obj, Bool_t lock)
Remove object from shared memory.
Definition TMapFile.cxx:699
Int_t ReleaseSemaphore()
Release semaphore. Returns 0 if OK, -1 on error.
Definition TMapFile.cxx:947
static void SetMapAddress(Longptr_t addr)
Set preferred map address.
char * fName
Name of mapped file.
Definition TMapFile.h:33
TMapFile()
Default ctor. Does not much except setting some basic values.
Definition TMapFile.cxx:211
char * fOption
Directory creation options.
Definition TMapFile.h:35
friend class TMapRec
Definition TMapFile.h:28
Int_t AcquireSemaphore()
Acquire semaphore. Returns 0 if OK, -1 on error.
Definition TMapFile.cxx:902
void Browse(TBrowser *b) override
Browse contents of TMapFile.
void Add(const TObject *obj, const char *name="")
Add an object to the list of objects to be stored in shared memory.
Definition TMapFile.cxx:611
static Longptr_t fgMapAddress
Map to this address, set address via SetMapAddress()
Definition TMapFile.h:52
Int_t GetBestBuffer()
Return the best buffer size for objects in this file.
TMapRec * GetFirst() const
Definition TMapFile.h:98
Keep track of an object in the mapped file.
Definition TMapFile.h:133
TObject * fObject
Pointer to original object.
Definition TMapFile.h:140
Int_t fBufSize
Buffer size.
Definition TMapFile.h:142
TMapRec(const TMapRec &)=delete
char * fName
Object name.
Definition TMapFile.h:138
const char * GetClassName(Longptr_t offset=0) const
Definition TMapFile.h:152
TMapRec * fNext
Next MapRec in list.
Definition TMapFile.h:143
TObject * GetObject() const
This method returns a pointer to the original object.
Definition TMapFile.cxx:198
const char * GetName(Longptr_t offset=0) const
Definition TMapFile.h:151
TMapRec * GetNext(Longptr_t offset=0) const
Definition TMapFile.h:156
void * GetBuffer(Longptr_t offset=0) const
Definition TMapFile.h:153
char * fClassName
Class name.
Definition TMapFile.h:139
void * fBuffer
Buffer containing object of class name.
Definition TMapFile.h:141
~TMapRec()
Destructor.
Definition TMapFile.cxx:186
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:888
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1001
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:973
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
static void SetDtorOnly(void *obj)
Set destructor only flag.
Definition TObject.cxx:1084
void MakeZombie()
Definition TObject.h:53
static Bool_t HasCustomNewDelete()
return the has custom delete flag
Definition TStorage.cxx:434
static void * ReAlloc(void *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition TStorage.cxx:183
Basic string class.
Definition TString.h:139
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:450
@ kIgnoreCase
Definition TString.h:279
static void ResetErrno()
Static function resetting system error number.
Definition TSystem.cxx:271
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1261
static Int_t GetErrno()
Static function returning system error number.
Definition TSystem.cxx:263
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1283
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1368
Abstract base class for TMapFile.
const Int_t n
Definition legend1.C:16
#define FALSE
Definition mesh.c:45
R__EXTERN TROOT * gROOTLocal
Definition TROOT.h:380
R__EXTERN GetMapFileMapllocDesc_t * gGetMapFileMallocDesc
Definition TStorage.h:142
R__EXTERN FreeIfTMapFile_t * gFreeIfTMapFile
Definition TStorage.h:141
R__EXTERN void * gMmallocDesc
Definition TStorage.h:143
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
Set ROOT::Internal::gFreeIfTMapFile on library load.
Definition TMapFile.cxx:158