#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. |
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 66 of file Init.defs.hh.
Parma_Polyhedra_Library::Init::Init | ( | ) |
Initializes the PPL.
Definition at line 60 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, set_GMP_memory_allocation_functions(), Parma_Polyhedra_Library::Variable::set_output_function(), and Parma_Polyhedra_Library::set_rational_sqrt_precision_parameter().
00060 { 00061 // Only when the first Init object is constructed... 00062 if (count++ == 0) { 00063 // ... the GMP memory allocation functions are set, ... 00064 set_GMP_memory_allocation_functions(); 00065 // ... the default output function for Variable objects is set, ... 00066 Variable::set_output_function(Variable::default_output_function); 00067 // ... the Coefficient constants are initialized, ... 00068 Coefficient_constants_initialize(); 00069 // ... the Linear_Expression class is initialized, ... 00070 Linear_Expression::initialize(); 00071 // ... the Constraint, Generator, Congruence, Grid_Generator, 00072 // Constraint_System, Generator_System, Congruence_System, 00073 // Grid_Generator_System and Polyhedron classes are initialized, ... 00074 Constraint::initialize(); 00075 Generator::initialize(); 00076 Congruence::initialize(); 00077 Grid_Generator::initialize(); 00078 Constraint_System::initialize(); 00079 Generator_System::initialize(); 00080 Congruence_System::initialize(); 00081 Grid_Generator_System::initialize(); 00082 Polyhedron::initialize(); 00083 #if PPL_CAN_CONTROL_FPU 00084 // ... and the FPU rounding direction is set. 00085 fpu_initialize_control_functions(); 00086 old_rounding_direction = fpu_get_rounding_direction(); 00087 fpu_set_rounding_direction(round_fpu_dir(ROUND_DIRECT)); 00088 #endif 00089 // FIXME: is 3200 a magic number? 00090 set_rational_sqrt_precision_parameter(3200); 00091 } 00092 }
Parma_Polyhedra_Library::Init::~Init | ( | ) |
Finalizes the PPL.
Definition at line 94 of file Init.cc.
References Parma_Polyhedra_Library::Coefficient_constants_finalize(), count, Parma_Polyhedra_Library::finalize(), and old_rounding_direction.
00094 { 00095 // Only when the last Init object is destroyed... 00096 if (--count == 0) { 00097 #if PPL_CAN_CONTROL_FPU 00098 // ... the FPU rounding direction is restored, ... 00099 fpu_set_rounding_direction(old_rounding_direction); 00100 #endif 00101 // ... the Polyhedron, Grid_Generator_System, Congruence_System, 00102 // Generator_System, Constraint_System, Grid_Generator, 00103 // Congruence, Generator and Constraint classes are finalized 00104 // IN THAT ORDER, ... 00105 Polyhedron::finalize(); 00106 Grid_Generator_System::finalize(); 00107 Congruence_System::finalize(); 00108 Generator_System::finalize(); 00109 Constraint_System::finalize(); 00110 Grid_Generator::finalize(); 00111 Congruence::finalize(); 00112 Generator::finalize(); 00113 Constraint::finalize(); 00114 // ... the Linear_Expression class is finalized, ... 00115 Linear_Expression::finalize(); 00116 // ... and the Coefficient constants are finalized. 00117 Coefficient_constants_finalize(); 00118 } 00119 }
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.
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.
unsigned int Parma_Polyhedra_Library::Init::count = 0 [static, private] |
PPL::fpu_rounding_direction_type Parma_Polyhedra_Library::Init::old_rounding_direction [static, private] |
Definition at line 77 of file Init.defs.hh.
Referenced by Init(), Parma_Polyhedra_Library::restore_pre_PPL_rounding(), and ~Init().