Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (14 years ago)
Author:
garnier
Message:

update ti head

Location:
trunk/source/global/management/include
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/global/management/include/G4Allocator.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4Allocator.hh,v 1.20 2010/03/30 08:17:24 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4Allocator.hh,v 1.21 2010/04/01 12:43:12 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    6666
    6767    inline void ResetStorage();
    68       // Returns allocated storage to the free store, resets
    69       // allocator and page sizes.
     68      // Returns allocated storage to the free store, resets allocator.
    7069      // Note: contents in memory are lost using this call !
    7170
    7271    inline size_t GetAllocatedSize() const;
    7372      // Returns the size of the total memory allocated
     73    inline int GetNoPages() const;
     74      // Returns the total number of allocated pages
     75    inline size_t GetPageSize() const;
     76      // Returns the current size of a page
     77    inline void IncreasePageSize( unsigned int sz );
     78      // Resets allocator and increases default page size of a given factor
    7479
    7580  public:  // without description
     
    213218
    214219// ************************************************************
     220// GetNoPages
     221// ************************************************************
     222//
     223template <class Type>
     224int G4Allocator<Type>::GetNoPages() const
     225{
     226  return mem.GetNoPages();
     227}
     228
     229// ************************************************************
     230// GetPageSize
     231// ************************************************************
     232//
     233template <class Type>
     234size_t G4Allocator<Type>::GetPageSize() const
     235{
     236  return mem.GetPageSize();
     237}
     238
     239// ************************************************************
     240// IncreasePageSize
     241// ************************************************************
     242//
     243template <class Type>
     244void G4Allocator<Type>::IncreasePageSize( unsigned int sz )
     245{
     246  ResetStorage();
     247  mem.GrowPageSize(sz);
     248}
     249
     250// ************************************************************
    215251// operator==
    216252// ************************************************************
  • trunk/source/global/management/include/G4AllocatorPool.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4AllocatorPool.hh,v 1.5 2006/06/29 19:01:18 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4AllocatorPool.hh,v 1.7 2010/07/14 10:45:46 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    5858      // Destructor. Return storage to the free store
    5959
    60     G4AllocatorPool(const G4AllocatorPool& right);
    61       // Copy constructor
    62 
    6360    inline void* Alloc();
    6461      // Allocate one element
     
    7168      // Return storage to the free store
    7269
     70    inline int  GetNoPages() const;
     71      // Return the total number of allocated pages
     72    inline unsigned int  GetPageSize() const;
     73      // Accessor for default page size
     74    inline void GrowPageSize( unsigned int factor );
     75      // Increase default page size by a given factor
     76
    7377  private:
    7478
     79    G4AllocatorPool(const G4AllocatorPool& right);
     80      // Provate copy constructor
    7581    G4AllocatorPool& operator= (const G4AllocatorPool& right);
    7682      // Private equality operator
     
    97103
    98104    const unsigned int esize;
    99     const unsigned int csize;
     105    unsigned int csize;
    100106    G4PoolChunk* chunks;
    101107    G4PoolLink* head;
     
    142148}
    143149
     150// ************************************************************
     151// GetNoPages
     152// ************************************************************
     153//
     154inline int
     155G4AllocatorPool::GetNoPages() const
     156{
     157  return nchunks;
     158}
     159
     160// ************************************************************
     161// GetPageSize
     162// ************************************************************
     163//
     164inline unsigned int
     165G4AllocatorPool::GetPageSize() const
     166{
     167  return csize;
     168}
     169
     170// ************************************************************
     171// GrowPageSize
     172// ************************************************************
     173//
     174inline void
     175G4AllocatorPool::GrowPageSize( unsigned int sz )
     176{
     177  csize = (sz) ? sz*csize : csize;
     178}
     179
    144180#endif
  • trunk/source/global/management/include/G4FPEDetection.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4FPEDetection.hh,v 1.2 2006/11/15 16:00:18 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4FPEDetection.hh,v 1.5 2010/10/14 17:02:52 mkelsey Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    3232//
    3333// -----------------------------------------------------------------------
    34 // This global method should be used on LINUX platforms with gcc compiler
    35 // for activating NaN detection and FPE signals, and forcing abortion of
    36 // the application at the time these are detected.
     34// This global method should be used on LINUX or MacOSX platforms with gcc
     35// compiler for activating NaN detection and FPE signals, and forcing
     36// abortion of the application at the time these are detected.
    3737// Meant to be used for debug purposes, can be activated by compiling the
    3838// "run" module with the flag G4FPE_DEBUG set in the environment.
     
    4141#ifndef G4FPEDetection_h
    4242#define G4FPEDetection_h 1
     43
     44#include <iostream>
     45#include <stdlib.h>  /* abort(), exit() */
    4346
    4447#ifdef __linux__
     
    4851  #include <csignal>
    4952
    50   #include <iostream>
    51 
    5253  struct sigaction termaction, oldaction;
    5354
    54   void TerminationSignalHandler(int sig)
     55  static void TerminationSignalHandler(int sig, siginfo_t* sinfo, void* /* context */)
    5556  {
    5657    std::cerr << "ERROR: " << sig;
    57     std::string message;
    58     switch (SIGFPE)
    59     {
     58    std::string message = "Floating-point exception (FPE).";
     59
     60    if (sinfo) {
     61      switch (sinfo->si_code) {
     62#ifdef FPE_NOOP         /* BUG: MacOSX uses this instead of INTDIV */
     63      case FPE_NOOP:
     64#endif
    6065      case FPE_INTDIV:
    6166        message = "Integer divide by zero.";
     
    8590        message = "Unknown error.";
    8691        break;
    87     }
     92      }
     93    }
     94
    8895    std::cerr << " - " << message << std::endl;
    89 
     96   
    9097    ::abort();
    9198  }
    9299
    93   void InvalidOperationDetection()
     100  static void InvalidOperationDetection()
    94101  {
    95102    std::cout << std::endl
     
    106113    //(void) feenableexcept( FE_UNDERFLOW );
    107114
    108     sigset_t *def_set;
    109     def_set=&termaction.sa_mask;
    110     sigfillset(def_set);
    111     sigdelset(def_set,SIGFPE);
    112     termaction.sa_handler=TerminationSignalHandler;
    113     termaction.sa_flags=0;
    114     sigaction(SIGFPE, &termaction,&oldaction);
    115   }
    116 #endif
    117 #else
    118   void InvalidOperationDetection() {;}
    119 #endif
    120 
    121 #endif
     115    sigdelset(&termaction.sa_mask,SIGFPE);
     116    termaction.sa_sigaction=TerminationSignalHandler;
     117    termaction.sa_flags=SA_SIGINFO;
     118    sigaction(SIGFPE, &termaction, &oldaction);
     119  }
     120#endif
     121#elif __MACH__      /* MacOSX */
     122
     123  #include <fenv.h>
     124  #include <signal.h>
     125
     126  #define DEFINED_PPC      (defined(__ppc__) || defined(__ppc64__))
     127  #define DEFINED_INTEL    (defined(__i386__) || defined(__x86_64__))
     128
     129  #if DEFINED_PPC
     130
     131    #define FE_EXCEPT_SHIFT 22  // shift flags right to get masks
     132    #define FM_ALL_EXCEPT    FE_ALL_EXCEPT >> FE_EXCEPT_SHIFT
     133
     134    static inline int feenableexcept (unsigned int excepts)
     135    {
     136      static fenv_t fenv;
     137      unsigned int new_excepts = (excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT,
     138                   old_excepts;  // all previous masks
     139
     140      if ( fegetenv (&fenv) )  { return -1; }
     141      old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
     142      fenv = (fenv & ~new_excepts) | new_excepts;
     143
     144      return ( fesetenv (&fenv) ? -1 : old_excepts );
     145    }
     146
     147    static inline int fedisableexcept (unsigned int excepts)
     148    {
     149      static fenv_t fenv;
     150      unsigned int still_on = ~((excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT),
     151                   old_excepts;  // previous masks
     152
     153      if ( fegetenv (&fenv) )  { return -1; }
     154      old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
     155      fenv &= still_on;
     156
     157      return ( fesetenv (&fenv) ? -1 : old_excepts );
     158    }
     159
     160  #elif DEFINED_INTEL
     161
     162    static inline int feenableexcept (unsigned int excepts)
     163    {
     164      static fenv_t fenv;
     165      unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
     166                   old_excepts;  // previous masks
     167
     168      if ( fegetenv (&fenv) )  { return -1; }
     169      old_excepts = fenv.__control & FE_ALL_EXCEPT;
     170
     171      // unmask
     172      //
     173      fenv.__control &= ~new_excepts;
     174      fenv.__mxcsr   &= ~(new_excepts << 7);
     175
     176      return ( fesetenv (&fenv) ? -1 : old_excepts );
     177    }
     178
     179    static inline int fedisableexcept (unsigned int excepts)
     180    {
     181      static fenv_t fenv;
     182      unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
     183                   old_excepts;  // all previous masks
     184
     185      if ( fegetenv (&fenv) )  { return -1; }
     186      old_excepts = fenv.__control & FE_ALL_EXCEPT;
     187
     188      // mask
     189      //
     190      fenv.__control |= new_excepts;
     191      fenv.__mxcsr   |= new_excepts << 7;
     192
     193      return ( fesetenv (&fenv) ? -1 : old_excepts );
     194    }
     195
     196  #endif  /* PPC or INTEL enabling */
     197
     198  static void TerminationSignalHandler(int sig, siginfo_t* sinfo, void* /* context */)
     199  {
     200    std::cerr << "ERROR: " << sig;
     201    std::string message = "Floating-point exception (FPE).";
     202
     203    if (sinfo) {
     204      switch (sinfo->si_code) {
     205#ifdef FPE_NOOP         /* BUG: MacOSX uses this instead of INTDIV */
     206      case FPE_NOOP:
     207#endif
     208      case FPE_INTDIV:
     209        message = "Integer divide by zero.";
     210        break;
     211      case FPE_INTOVF:
     212        message = "Integer overflow.";
     213        break;
     214      case FPE_FLTDIV:
     215        message = "Floating point divide by zero.";
     216        break;
     217      case FPE_FLTOVF:
     218        message = "Floating point overflow.";
     219        break;
     220      case FPE_FLTUND:
     221        message = "Floating point underflow.";
     222        break;
     223      case FPE_FLTRES:
     224        message = "Floating point inexact result.";
     225        break;
     226      case FPE_FLTINV:
     227        message = "Floating point invalid operation.";
     228        break;
     229      case FPE_FLTSUB:
     230        message = "Subscript out of range.";
     231        break;
     232      default:
     233        message = "Unknown error.";
     234        break;
     235      }
     236    }
     237
     238    std::cerr << " - " << message << std::endl;
     239   
     240    ::abort();
     241  }
     242
     243  static void InvalidOperationDetection()
     244  {
     245    struct sigaction termaction, oldaction;
     246
     247    std::cout << std::endl
     248              << "        "
     249              << "############################################" << std::endl
     250              << "        "
     251              << "!!! WARNING - FPE detection is activated !!!" << std::endl
     252              << "        "
     253              << "############################################" << std::endl;
     254
     255    feenableexcept ( FE_DIVBYZERO );
     256    feenableexcept ( FE_INVALID   );
     257    // fedisableexcept( FE_OVERFLOW  );
     258    // fedisableexcept( FE_UNDERFLOW );
     259
     260    sigdelset(&termaction.sa_mask,SIGFPE);
     261    termaction.sa_sigaction=TerminationSignalHandler;
     262    termaction.sa_flags=SA_SIGINFO;
     263    sigaction(SIGFPE, &termaction, &oldaction);
     264  }
     265#else  /* Not Linux, nor MacOSX ... */
     266
     267  static void InvalidOperationDetection() {;}
     268
     269#endif
     270
     271#endif
  • trunk/source/global/management/include/G4PhysicsVector.icc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4PhysicsVector.icc,v 1.28 2010/05/28 05:13:43 kurasige Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4PhysicsVector.icc,v 1.30 2010/09/20 16:22:56 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
  • trunk/source/global/management/include/G4Pow.hh

    r1337 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Pow.hh,v 1.5 2010/05/28 08:18:03 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4Pow.hh,v 1.7 2010/08/24 08:12:08 gcosmo Exp $
     27// GEANT4 tag $Name: global-V09-03-22 $
    2828//
    2929//
     
    8282    inline G4double powZ(G4int Z, G4double y);
    8383    inline G4double powA(G4double A, G4double y);
     84           G4double powN(G4double x, G4int n);
    8485
    8586    // Fast factorial
    8687    //
    8788    inline G4double factorial(G4int Z);
     89    inline G4double logfactorial(G4int Z);
    8890
    8991  private:
     
    101103    G4DataVector lz;
    102104    G4DataVector fact;
     105    G4DataVector logfact;
    103106};
    104107
     
    190193}
    191194
     195inline G4double G4Pow::logfactorial(G4int Z)
     196{
     197  return logfact[Z];
     198}
     199
    192200// -------------------------------------------------------------------
    193201
  • trunk/source/global/management/include/G4ios.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4ios.hh,v 1.10 2006/06/29 19:03:43 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ios.hh,v 1.12 2010/10/27 07:40:06 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    4242#include <iostream>
    4343
    44 #if defined G4IOS_EXPORT
     44#if defined G4IOS_ALLOC_EXPORT
    4545  extern G4DLLEXPORT std::ostream G4cout;
    4646  extern G4DLLEXPORT std::ostream G4cerr;
  • trunk/source/global/management/include/G4strstreambuf.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4strstreambuf.hh,v 1.16 2007/11/13 17:35:06 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4strstreambuf.hh,v 1.18 2010/10/27 07:40:06 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929// ====================================================================
    3030//
     
    4141class G4strstreambuf;
    4242
    43 #if defined G4IOS_EXPORT
     43#if defined G4IOS_ALLOC_EXPORT
    4444extern G4DLLEXPORT G4strstreambuf G4coutbuf;
    4545extern G4DLLEXPORT G4strstreambuf G4cerrbuf;
  • trunk/source/global/management/include/templates.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: templates.hh,v 1.13 2008/08/15 12:15:53 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: templates.hh,v 1.14 2010/07/16 15:48:51 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    109109#endif
    110110
     111#ifndef INT_MAX   /* Max decimal value of a int */
     112#define INT_MAX   std::numeric_limits<int>::max()   // 2147483647
     113#endif
     114
     115#ifndef INT_MIN   /* Min decimal value of a int */
     116#define INT_MIN   std::numeric_limits<int>::min()   // -2147483648
     117#endif
     118
    111119//---------------------------------
    112120
Note: See TracChangeset for help on using the changeset viewer.