![]() |
|
|
Bdb packages | Design docs | Source docs | Guidelines | Recent releases |
|
Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members /BaBar/BaBar.hh
Go to the documentation of this file.00001 #ifndef BABAR_HH 00002 #define BABAR_HH 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: BaBar.hh,v 1.76 2002/06/12 20:14:44 echarles Exp $ 00007 // 00008 // Description: 00009 // Standard include file to contain global "fixes" 00010 // and type definitions 00011 // 00012 // This file is intended to be included by _lots_ of others 00013 // so should stay very light-weight. In particular, definitions 00014 // of static variables are not appropriate here, as they 00015 // will allocate memory in every BaBar object file. 00016 // 00017 // Environment: 00018 // Software developed for the BaBar Detector at the SLAC B-Factory. 00019 // 00020 // Author List: 00021 // David Quarrie 00022 // Bob Jacobsen (added F90 interface types, fixed bool, Mar 19,95) 00023 // Forest Rouse (added pi, bznom, chisq_undef, and epsilon) 00024 // Abi Soffer (added BbrLorentzVector) 00025 // A. De Silva (moved macros from Framework/APPModule.hh. Jan 29,99) 00026 // 00027 // Copyright Information: 00028 // Copyright (C) 1995, 1996 00029 // 00030 //------------------------------------------------------------------------ 00031 00032 // Fix up "bool" for non-conforming compilers 00033 // 00034 // The idea here is that new code _should_ be written to 00035 // conform to the C++ standard, i.e. with a built in bool 00036 // type. Name conflicts, etc, are _bugs_ and should be 00037 // fixed in the source. 00038 // 00039 // This will be removed in the spring of 1996, after which time 00040 // only conforming compilers will be supported 00041 // 00042 00043 00044 00045 00046 #if defined(__SUNPRO_CC) && defined(__SunOS_5_8) 00047 class ostream; 00048 class istream; 00049 00050 namespace std { 00051 template <class T > class allocator; 00052 template <class charT> struct char_traits; 00053 template <class charT, class traits , class Allocator > class basic_string; 00054 typedef basic_string<char, char_traits<char>, allocator<char> > string; 00055 } 00056 00057 ostream& operator<<(ostream& s,const std::string& str); 00058 istream &operator>>(istream &s, std::string& str); 00059 00060 #endif 00061 00062 00063 // fix up "bool" definition for pre2.6.x g++ compilers 00064 00065 #if defined(__GNUG__) && (__GNUC_MINOR__ >= 6) 00066 // This definition to avoid problems with CLHEP 00067 #define HAS_BUILTIN_BOOL 00068 #endif 00069 00070 // fixup bool for VxWorks 00071 00072 #if defined(VXWORKS) 00073 #define HAS_BUILTIN_BOOL 00074 #endif 00075 00076 #if defined(__GNUG__) && (__GNUC_MINOR__ < 6) 00077 #ifndef CHAR_BOOL 00078 #define CHAR_BOOL 00079 ////enum bool {false=0, true=-1}; 00080 typedef char bool; 00081 const bool false = 0; 00082 const bool true = 1; 00083 #endif 00084 #endif 00085 00086 // fix up "bool" definition for vendor compilers. 00087 // 00088 // Note that the enum above has problems with function values, which is 00089 // why the following uses a typedef & macros. Perhaps they should be combined? 00090 00091 #if defined(_MSC_VER) || defined(__XLC__) || defined( HP1022 ) 00092 #include "BaBar/BaBarBool.hh" 00093 #endif 00094 00095 #if defined( sun ) && (__SUNPRO_CC < 0x500) 00096 #include "BaBar/BaBarBool.hh" 00097 #endif 00098 00099 // Make sure that we cover all bases in telling the code that 00100 // aCC has "bool" NiG 20-Oct-1997 00101 #ifdef HPaCC 00102 #define HAS_BUILTIN_BOOL 00103 #define HEP_HAVE_BOOL 00104 #endif 00105 00106 // fix up abs(double) et al on Linux and DEC 00107 #if defined(__DECCXX) || defined(__linux__) 00108 #ifndef BABAR_ABS_PATCH 00109 #define BABAR_ABS_PATCH 00110 static inline float abs(float x) { return x<0 ? -x : x;} 00111 static inline double abs(double x) { return x<0 ? -x : x;} 00112 00113 // static inline long abs(long n) {return n<0 ? -n : n;} 00114 // ROOT's CINT cannot handle the types long long or long double 00115 #ifndef __CINT__ 00116 static inline long double abs(long double x) { return x<0 ? -x : x;} 00117 static inline long long abs(long long n) {return n<0 ? -n : n;} 00118 #endif // __CINT__ 00119 #endif // BABAR_ABS_PATCH 00120 #endif // OSF || Linux 00121 00122 #if defined(sun) 00123 #ifndef BABAR_ABS_PATCH 00124 #define BABAR_ABS_PATCH 00125 #if (__SUNPRO_CC >= 0x500) 00126 template < class T > 00127 static inline T abs( T a ) 00128 { 00129 return a < 0 ? -a : a; 00130 } 00131 #else // CC < 5.0 00132 static inline float abs(float x) { return x<0 ? -x : x;} 00133 static inline long double abs(long double x) { return x<0 ? -x : x;} 00134 static inline double abs(double x) { return x<0 ? -x : x;} 00135 00136 static inline long abs(long n) {return n<0 ? -n : n;} 00137 // ROOT's CINT cannot handle the type long long 00138 #ifndef __CINT__ 00139 static inline long long abs(long long n) {return n<0 ? -n : n;} 00140 #endif // __CINT__ 00141 #endif // CC >=5.0 00142 #endif // BABAR_ABS_PATCH 00143 #endif // sun 00144 00145 // Define very large integer types. These types are required by the 00146 // POSIX specification. 00147 00148 #if defined(sun) || defined(__DECCXX) || defined(__linux__) 00149 // ROOT's CINT cannot handle the type long long 00150 #ifndef __CINT__ 00151 typedef long long int64_t; 00152 typedef unsigned long long uint64_t; 00153 #endif 00154 #endif 00155 00156 00157 // Activate large file support for Sun if it isn't already. 00158 // This should be done in CPPFLAGS (and is) but a bug in the template 00159 // support in the Workshop 4.2 compiler causes some files to be 00160 // compiled with _FILE_OFFSET_BITS set to "'64'" instead of "64". // FIXME 00161 // NB: This _MUST_ be done before <sys/feature_tests.h> is included. 00162 #if defined(sun) 00163 #ifdef _LARGEFILE_SOURCE 00164 #undef _LARGEFILE_SOURCE 00165 #endif 00166 #define _LARGEFILE_SOURCE 1 00167 #ifdef _FILE_OFFSET_BITS 00168 #undef _FILE_OFFSET_BITS 00169 #endif 00170 #define _FILE_OFFSET_BITS 64 00171 #endif // Sun 00172 00173 00174 // The following two "paragraphs" of code seem to make the ROOT 00175 // interpreter unhappy. For now we protect it from them. This is 00176 // not an ideal solution. // FIXME 00177 #ifndef __CINT__ 00178 00179 // Load the various platforms' feature-test include files, so that we 00180 // can properly take advantage of the various *POSIX* and *XOPEN* macros. 00181 // There is no way to do this in a platform-independent way without 00182 // loading something heavyweight like <unistd.h>, which might affect 00183 // code that doesn't want it. [gpdf 2001.01.29] 00184 #ifdef sun 00185 #include <sys/feature_tests.h> 00186 #else 00187 #ifdef __DECCXX 00188 #include <standards.h> 00189 #else 00190 #ifdef __linux__ 00191 #include <features.h> 00192 #else 00193 // Don't know what to do here. Try loading a lightweight include file. 00194 // On some platforms this brings in the feature tests, but not on all. 00195 #include <stddef.h> 00196 #endif 00197 #endif 00198 #endif 00199 00200 00201 // Accommodate the variations in the adoption of socklen_t from Unix98. 00202 // Unix98 (XPG5) has socklen_t. Unix95 (XPG4v2) uses size_t (which is 00203 // typically unsigned) in places where socklen_t appears in Unix98. 00204 // Pre-standard APIs tend to have int instead. [added gpdf 2001.01.29] 00205 #if ( defined(_XOPEN_SOURCE) && ( _XOPEN_SOURCE - 0 ) >= 500 ) 00206 // Unix98 (XPG5): Solaris 7 with -D_XOPEN_SOURCE=500, Linux 00207 #define BABAR_socklen_t socklen_t 00208 #else 00209 #ifdef _XOPEN_SOURCE_EXTENDED 00210 // Unix95 (XPG4v2): OSF, Solaris 2.6 with -D_XOPEN_SOURCE_EXTENDED 00211 #define BABAR_socklen_t size_t 00212 #else 00213 // pre-standard: Solaris 7 & 2.6 "plain vanilla" 00214 #define BABAR_socklen_t int 00215 #endif 00216 #endif 00217 00218 #endif // ifndef __CINT__ 00219 00220 00221 // Provide the strsignal() function if the system does not; it's in the 00222 // system libraries on Solaris and Linux/glibc. 00223 // Implemented in BaBar/strsignal.cc. 00224 #if defined(__osf__) 00225 // This one we actually have to implement. 00226 extern "C" char* strsignal( int sig ); 00227 #elif defined(__sun) && \ 00228 ( !defined(__EXTENSIONS__) && \ 00229 ( defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) ) ) 00230 // This one is in the libraries on Solaris but only has a prototype 00231 // defined in <signal.h> if pure-Unix95/98 compilation is not in force. 00232 // We just restore the prototype. 00233 extern "C" char* strsignal( int sig ); 00234 #endif 00235 00236 00237 // Various system files are missing the following on Linux at the 00238 // moment (egcs 1.1.1 and glibc-2.0.7) 00239 #if defined(__linux__) 00240 00241 // BdbAccess uses regex and regcmp which should be in libgen.h 00242 char* regcmp( const char *string1, ... ); 00243 char* regex( const char *re, const char *subject, ... ); 00244 00245 // The following problems are fixed in glibc 2.2 00246 #if ( __GLIBC__==2 ) && ( __GLIBC_MINOR__<2 ) 00247 00248 // No clock_gettime in <time.h> 00249 typedef int clockid_t; 00250 #ifndef CLOCK_REALTIME 00251 #define CLOCK_REALTIME 0 00252 #endif 00253 00254 // ROOT's CINT has a problem with timespec not being defined 00255 #ifndef __CINT__ 00256 int clock_gettime ( clockid_t clock_id, struct timespec *tp); 00257 #endif 00258 00259 // No in_addr_t, used in BdbTransfer from 8.2.1 00260 typedef unsigned long int in_addr_t; 00261 00262 // This signal isn't defined before Linux kernel 2.1.3 but is Unix98-ish 00263 // and is used in TaoTools. 00264 #ifndef SIGSYS 00265 #define SIGSYS 31 00266 #endif // SIGSYS 00267 00268 #endif // glibc <2.2 00269 00270 #endif // __linux__ 00271 00272 // An error in the construction of the system and C++ header files on 00273 // Solaris 8 / Workshop 6 Updates 1&2 leads to a conflict between the use 00274 // of ::clock_t and std::clock_t when <string> is compiled under 00275 // -D_XOPEN_SOURCE=500. The following code ensures that ::clock_t is 00276 // always defined and thus allows <string> to compile. 00277 // This is just a workaround and should be monitored as compiler and 00278 // operating system versions evolve. [gpdf 2002.02.05] 00279 // Modified to test on SUNCC so as to make the ddl compiler pick 00280 // up this fix [ryd 2002.01.15] 00281 #if defined(SUNCC) && defined(_XOPEN_SOURCE) && ( _XOPEN_SOURCE - 0 == 500 ) 00282 #ifndef _CLOCK_T 00283 #define _CLOCK_T 00284 typedef long clock_t; /* relative time in a specified resolution */ 00285 #endif /* ifndef _CLOCK_T */ 00286 #endif 00287 00288 #if defined(__SUNPRO_CC) && defined(__SunOS_5_8) 00289 class ostream; 00290 class istream; 00291 00292 namespace std { 00293 template <class T > class allocator; 00294 template <class charT> struct char_traits; 00295 template <class charT, class traits , class Allocator > class basic_string; 00296 typedef basic_string<char, char_traits<char>, allocator<char> > string; 00297 } 00298 00299 ostream& operator<<(ostream& s,const std::string& str); 00300 istream &operator>>(istream &s, std::string& str); 00301 istream& getline(istream& is, std::string& str, char delim = '\n'); 00302 00303 #endif 00304 00305 #endif // BABAR_HH
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002