00001 /* Init class implementation (non-inline functions and static variables). 00002 Copyright (C) 2001-2008 Roberto Bagnara <bagnara@cs.unipr.it> 00003 00004 This file is part of the Parma Polyhedra Library (PPL). 00005 00006 The PPL is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU General Public License as published by the 00008 Free Software Foundation; either version 3 of the License, or (at your 00009 option) any later version. 00010 00011 The PPL is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software Foundation, 00018 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00019 00020 For the most up-to-date information see the Parma Polyhedra Library 00021 site: http://www.cs.unipr.it/ppl/ . */ 00022 00023 #include <ppl-config.h> 00024 00025 #include "Init.defs.hh" 00026 #include "Variable.defs.hh" 00027 #include "fpu.defs.hh" 00028 #include "Rounding_Dir.defs.hh" 00029 #include "checked.defs.hh" 00030 #include "Coefficient.defs.hh" 00031 #include "Linear_Expression.defs.hh" 00032 #include "Constraint.defs.hh" 00033 #include "Generator.defs.hh" 00034 #include "Congruence.defs.hh" 00035 #include "Grid_Generator.defs.hh" 00036 #include "Constraint_System.defs.hh" 00037 #include "Generator_System.defs.hh" 00038 #include "Congruence_System.defs.hh" 00039 #include "Grid_Generator_System.defs.hh" 00040 #include "Polyhedron.defs.hh" 00041 00042 namespace PPL = Parma_Polyhedra_Library; 00043 00044 unsigned int PPL::Init::count = 0; 00045 00046 PPL::fpu_rounding_direction_type PPL::Init::old_rounding_direction; 00047 00048 extern "C" void 00049 set_GMP_memory_allocation_functions(void) 00050 #if PPL_CXX_SUPPORTS_ATTRIBUTE_WEAK 00051 __attribute__((weak)); 00052 00053 void 00054 set_GMP_memory_allocation_functions(void) { 00055 } 00056 #else 00057 ; 00058 #endif 00059 00060 PPL::Init::Init() { 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 } 00093 00094 PPL::Init::~Init() { 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 }