Geant4_10
G4HadSignalHandler.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 #ifndef G4HadSignalHandler_off
27 
28 #include "G4HadSignalHandler.hh"
29 
30 namespace G4HadSignalHandler_local
31 {
32  extern "C"
33  {
34  void HandleIt(int i);
35  static void (*G4HadSignalHandler_initial)(int);
36  }
37 }
38 
39 using namespace std;
40 
41 G4ThreadLocal std::vector<sighandler_t> *G4HadSignalHandler::theCache_G4MT_TLS_ = 0;
43 
45 { ;;; if (!theCache_G4MT_TLS_) theCache_G4MT_TLS_ = new std::vector<sighandler_t> ; std::vector<sighandler_t> &theCache = *theCache_G4MT_TLS_; ;;;
46  if(!registered)
47  {
48  G4HadSignalHandler_local::G4HadSignalHandler_initial =
49  signal(SIGSEGV, G4HadSignalHandler_local::HandleIt);
50  registered = true;
51  }
52  theCache.push_back(aNew);
53 }
54 
56 { ;;; if (!theCache_G4MT_TLS_) theCache_G4MT_TLS_ = new std::vector<sighandler_t> ; std::vector<sighandler_t> &theCache = *theCache_G4MT_TLS_; ;;;
57  theCache.clear();
58  signal (SIGSEGV, G4HadSignalHandler_local::G4HadSignalHandler_initial);
59  registered = false;
60 }
61 
63 {
64  static G4ThreadLocal int *iii_G4MT_TLS_ = 0 ; if (!iii_G4MT_TLS_) {iii_G4MT_TLS_ = new int ; *iii_G4MT_TLS_=G4HadSignalHandler::theCache_G4MT_TLS_->size()-1 ; } int &iii = *iii_G4MT_TLS_;
65  for(int c=iii; c!=-1; c--)
66  {
67  iii--;
68  //Andrea Dotti (13Jan2013): change for G4MT
69  (G4HadSignalHandler::theCache_G4MT_TLS_->operator[](c))(i);
70  //G4HadSignalHandler::theCache[c](i);
71  }
72  std::cerr << "callback to user-defined or default signal handler"<<endl;
73  signal (SIGSEGV, G4HadSignalHandler_local::G4HadSignalHandler_initial);
74  raise(i);
75 }
76 
77 #endif
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4HadSignalHandler(sighandler_t aNew)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
#define G4ThreadLocal
Definition: tls.hh:52
static G4ThreadLocal std::vector< sighandler_t > * theCache_G4MT_TLS_
void(* sighandler_t)(int)
tuple c
Definition: test.py:13
static G4ThreadLocal bool registered