00001 /* Init class implementation (non-inline functions and static variables). 00002 Copyright (C) 2001-2006 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 2 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 <config.h> 00024 00025 #include "Init.defs.hh" 00026 #include "Variable.defs.hh" 00027 #include "fpu.defs.hh" 00028 #include "checked.defs.hh" 00029 00030 namespace PPL = Parma_Polyhedra_Library; 00031 00032 unsigned int PPL::Init::count = 0; 00033 00034 PPL::fpu_rounding_direction_type PPL::Init::old_rounding_direction; 00035 00036 extern "C" void 00037 set_GMP_memory_allocation_functions(void) 00038 #if CXX_SUPPORTS_ATTRIBUTE_WEAK 00039 __attribute__((weak)); 00040 00041 void 00042 set_GMP_memory_allocation_functions(void) { 00043 } 00044 #else 00045 ; 00046 #endif 00047 00048 PPL::Init::Init() { 00049 // Only when the first Init object is constructed... 00050 if (count++ == 0) { 00051 // ... the GMP memory allocation functions are set, ... 00052 set_GMP_memory_allocation_functions(); 00053 // ... and the default output function for Variable objects is set. 00054 Variable::set_output_function(Variable::default_output_function); 00055 #if PPL_CAN_CONTROL_FPU 00056 old_rounding_direction = fpu_get_rounding_direction(); 00057 fpu_set_rounding_direction(ROUND_DIRECT); 00058 #endif 00059 // FIXME: is 3200 a magic number? 00060 set_rational_sqrt_precision_parameter(3200); 00061 } 00062 } 00063 00064 PPL::Init::~Init() { 00065 // Only when the last Init object is destroyed... 00066 if (--count == 0) { 00067 #if PPL_CAN_CONTROL_FPU 00068 fpu_set_rounding_direction(old_rounding_direction); 00069 #endif 00070 } 00071 }