File: Debug.cc

package info (click to toggle)
thepeg 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 9,312 kB
  • ctags: 11,509
  • sloc: cpp: 57,129; sh: 11,315; java: 3,212; lisp: 1,402; makefile: 830; ansic: 58; perl: 3
file content (188 lines) | stat: -rw-r--r-- 3,366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// -*- C++ -*-
//
// Debug.cc is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
//
// This is the implementation of the non-inlined, non-templated member
// functions of the Debug class.
//

#include "Debug.h"
#include "config.h"
#ifdef ThePEG_HAS_FPU_CONTROL
#include <fpu_control.h>
#endif
#ifdef ThePEG_HAS_FENV
#include <fenv.h>
#endif

using namespace ThePEG;

int Debug::level = 0;

bool Debug::isset = false;

std::vector<bool> Debug::debugItems;

void Debug::debugItem(int item, bool on) {
  if ( item < 0 ) return;
  debugItems.resize(item + 1, false);
  debugItems[item] = on;
}

void Debug::setDebug(int ilev) {
  if ( ilev < 0 ) debugItem(-ilev, true);
  else {
    level = ilev;
    isset = true;
  }
}

void Debug::unmaskFpuErrors() {
  unmaskFpuOverflow();
  unmaskFpuDivZero();
  //  unmaskFpuDenorm();
  unmaskFpuInvalid();
}

void Debug::unmaskFpuOverflow() {
#ifdef ThePEG_HAS_FENV
  feenableexcept(FE_OVERFLOW);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw &= ~(_FPU_MASK_OM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::unmaskFpuUnderflow() {
#ifdef ThePEG_HAS_FENV
  feenableexcept(FE_UNDERFLOW);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw &= ~(_FPU_MASK_UM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::unmaskFpuDivZero() {
#ifdef ThePEG_HAS_FENV
  feenableexcept(FE_DIVBYZERO);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw &= ~(_FPU_MASK_ZM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::unmaskFpuDenorm() {
#ifdef ThePEG_HAS_FENV
  feenableexcept(FE_INEXACT);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw &= ~(_FPU_MASK_DM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::unmaskFpuInvalid()  {
#ifdef ThePEG_HAS_FENV
  feenableexcept(FE_INVALID);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw &= ~(_FPU_MASK_IM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::maskFpuErrors() {
  maskFpuOverflow();
  maskFpuDivZero();
  maskFpuDenorm();
  maskFpuInvalid();
}

void Debug::maskFpuOverflow() {
#ifdef ThePEG_HAS_FENV
  fedisableexcept(FE_OVERFLOW);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw |= (_FPU_MASK_OM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::maskFpuUnderflow() {
#ifdef ThePEG_HAS_FENV
  fedisableexcept(FE_UNDERFLOW);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw |= (_FPU_MASK_UM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::maskFpuDivZero() {
#ifdef ThePEG_HAS_FENV
  fedisableexcept(FE_DIVBYZERO);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw |= (_FPU_MASK_ZM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::maskFpuDenorm() {
#ifdef ThePEG_HAS_FENV
  fedisableexcept(FE_INEXACT);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw |= (_FPU_MASK_DM);
  _FPU_SETCW(cw);
#endif
#endif
}

void Debug::maskFpuInvalid() {
#ifdef ThePEG_HAS_FENV
  fedisableexcept(FE_INVALID);
#else
#ifdef ThePEG_HAS_FPU_CONTROL
  fpu_control_t cw;
  _FPU_GETCW(cw);
  cw |= (_FPU_MASK_IM);
  _FPU_SETCW(cw);
#endif
#endif
}