Class for initialization and finalization. More...
#include <Init.defs.hh>
Public Member Functions | |
| Init () | |
| Initializes the PPL. | |
| ~Init () | |
| Finalizes the PPL. | |
Static Private Attributes | |
| static unsigned int | count = 0 |
| Count the number of objects created. | |
| static fpu_rounding_direction_type | old_rounding_direction |
Friends | |
| void | set_rounding_for_PPL () |
| Sets the FPU rounding mode so that the PPL abstractions based on floating point numbers work correctly. | |
| void | restore_pre_PPL_rounding () |
| Sets the FPU rounding mode as it was before initialization of the PPL. | |
Class for initialization and finalization.
Nifty Counter initialization class, ensuring that the library is initialized only once and before its first use. A count of the number of translation units using the library is maintained. A static object of Init type will be declared by each translation unit using the library. As a result, only one of them will initialize and properly finalize the library.
Definition at line 67 of file Init.defs.hh.
| Parma_Polyhedra_Library::Init::Init | ( | ) |
Initializes the PPL.
Definition at line 137 of file Init.cc.
References Parma_Polyhedra_Library::Coefficient_constants_initialize(), count, Parma_Polyhedra_Library::Variable::default_output_function(), Parma_Polyhedra_Library::initialize(), old_rounding_direction, ppl_set_GMP_memory_allocation_functions(), Parma_Polyhedra_Library::set_irrational_precision(), and Parma_Polyhedra_Library::Variable::set_output_function().
00137 { 00138 // Only when the first Init object is constructed... 00139 if (count++ == 0) { 00140 // ... the GMP memory allocation functions are set, ... 00141 ppl_set_GMP_memory_allocation_functions(); 00142 // ... the default output function for Variable objects is set, ... 00143 Variable::set_output_function(Variable::default_output_function); 00144 // ... the Coefficient constants are initialized, ... 00145 Coefficient_constants_initialize(); 00146 // ... the Linear_Expression class is initialized, ... 00147 Linear_Expression::initialize(); 00148 // ... the Constraint, Generator, Congruence, Grid_Generator, 00149 // Constraint_System, Generator_System, Congruence_System, 00150 // Grid_Generator_System and Polyhedron classes are initialized, ... 00151 Constraint::initialize(); 00152 Generator::initialize(); 00153 Congruence::initialize(); 00154 Grid_Generator::initialize(); 00155 Constraint_System::initialize(); 00156 Generator_System::initialize(); 00157 Congruence_System::initialize(); 00158 Grid_Generator_System::initialize(); 00159 Polyhedron::initialize(); 00160 00161 #if PPL_CAN_CONTROL_FPU 00162 00163 // ... and the FPU rounding direction is set. 00164 fpu_initialize_control_functions(); 00165 old_rounding_direction = fpu_get_rounding_direction(); 00166 fpu_set_rounding_direction(round_fpu_dir(ROUND_DIRECT)); 00167 00168 #if defined(PPL_ARM_CAN_CONTROL_FPU) && PPL_ARM_CAN_CONTROL_FPU 00169 if (ppl_test_rounding() != 0) 00170 throw std::logic_error("PPL configuration error:" 00171 " PPL_ARM_CAN_CONTROL_FPU evaluates to true," 00172 " but rounding does not work."); 00173 #endif // defined(PPL_ARM_CAN_CONTROL_FPU) && PPL_ARM_CAN_CONTROL_FPU 00174 00175 #endif // PPL_CAN_CONTROL_FPU 00176 00177 // The default is choosen to have a precision greater than most 00178 // precise IEC559 floating point (112 bits of mantissa). 00179 set_irrational_precision(128); 00180 } 00181 }
| Parma_Polyhedra_Library::Init::~Init | ( | ) |
Finalizes the PPL.
Definition at line 183 of file Init.cc.
References Parma_Polyhedra_Library::Coefficient_constants_finalize(), count, Parma_Polyhedra_Library::finalize(), and old_rounding_direction.
00183 { 00184 // Only when the last Init object is destroyed... 00185 if (--count == 0) { 00186 #if PPL_CAN_CONTROL_FPU 00187 // ... the FPU rounding direction is restored, ... 00188 fpu_set_rounding_direction(old_rounding_direction); 00189 #endif 00190 // ... the Polyhedron, Grid_Generator_System, Congruence_System, 00191 // Generator_System, Constraint_System, Grid_Generator, 00192 // Congruence, Generator and Constraint classes are finalized 00193 // IN THAT ORDER, ... 00194 Polyhedron::finalize(); 00195 Grid_Generator_System::finalize(); 00196 Congruence_System::finalize(); 00197 Generator_System::finalize(); 00198 Constraint_System::finalize(); 00199 Grid_Generator::finalize(); 00200 Congruence::finalize(); 00201 Generator::finalize(); 00202 Constraint::finalize(); 00203 // ... the Linear_Expression class is finalized, ... 00204 Linear_Expression::finalize(); 00205 // ... and the Coefficient constants are finalized. 00206 Coefficient_constants_finalize(); 00207 } 00208 }
| void restore_pre_PPL_rounding | ( | ) | [friend] |
Sets the FPU rounding mode as it was before initialization of the PPL.
After calling this function it is absolutely necessary to call set_rounding_for_PPL() before using any PPL abstractions based on floating point numbers. This is performed automatically at finalization-time.
Definition at line 40 of file Init.inlines.hh.
00040 { 00041 #if PPL_CAN_CONTROL_FPU 00042 fpu_set_rounding_direction(Init::old_rounding_direction); 00043 #endif 00044 }
| void set_rounding_for_PPL | ( | ) | [friend] |
Sets the FPU rounding mode so that the PPL abstractions based on floating point numbers work correctly.
This is performed automatically at initialization-time. Calling this function is needed only if restore_pre_PPL_rounding() has been previously called.
Definition at line 33 of file Init.inlines.hh.
unsigned int Parma_Polyhedra_Library::Init::count = 0 [static, private] |
Count the number of objects created.
Definition at line 77 of file Init.defs.hh.
PPL::fpu_rounding_direction_type Parma_Polyhedra_Library::Init::old_rounding_direction [static, private] |
Definition at line 78 of file Init.defs.hh.
Referenced by Init(), Parma_Polyhedra_Library::restore_pre_PPL_rounding(), and ~Init().
1.6.3