1 //////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (C) 2016-2021 The Octave Project Developers 4 // 5 // See the file COPYRIGHT.md in the top-level directory of this 6 // distribution or <https://octave.org/copyright/>. 7 // 8 // This file is part of Octave. 9 // 10 // Octave is free software: you can redistribute it and/or modify it 11 // under the terms of the GNU General Public License as published by 12 // the Free Software Foundation, either version 3 of the License, or 13 // (at your option) any later version. 14 // 15 // Octave is distributed in the hope that it will be useful, but 16 // WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of the GNU General Public License 21 // along with Octave; see the file COPYING. If not, see 22 // <https://www.gnu.org/licenses/>. 23 // 24 //////////////////////////////////////////////////////////////////////// 25 26 // The fpucw macros are provided by gnulib. We don't include gnulib 27 // headers directly in Octave's C++ source files to avoid problems that 28 // may be caused by the way that gnulib overrides standard library 29 // functions. 30 31 #if defined (HAVE_CONFIG_H) 32 # include "config.h" 33 #endif 34 35 #if defined (HAVE_FPU_CONTROL_H) 36 # include <fpu_control.h> 37 #endif 38 39 #include "fpucw.h" 40 41 #include "fpucw-wrappers.h" 42 43 #if ! defined (_FPU_DEFAULT) 44 # if defined __i386__ || defined __x86_64__ 45 # define _FPU_DEFAULT 0x037f 46 # else 47 # define _FPU_DEFAULT 0 48 # endif 49 #endif 50 51 void octave_set_default_fpucw(void)52octave_set_default_fpucw (void) 53 { 54 fpucw_t cw = GET_FPUCW (); 55 56 if (cw != _FPU_DEFAULT) 57 SET_FPUCW (_FPU_DEFAULT); 58 } 59 60 // OLDCW is the name used by the fpucw.h macros and gnulib doesn't give 61 // us a choice. We are also assuming that fpucw_t is unsigned, and no 62 // wider than an int. 63 64 unsigned int octave_begin_long_double_rounding(void)65octave_begin_long_double_rounding (void) 66 { 67 // Don't use DECL_LONG_DOUBLE_ROUNDING here because on some systems, 68 // it is defined to be empty. 69 70 fpucw_t oldcw = 0; 71 72 BEGIN_LONG_DOUBLE_ROUNDING (); 73 74 return oldcw; 75 } 76 77 void octave_end_long_double_rounding(unsigned int oldcw)78octave_end_long_double_rounding (unsigned int oldcw) 79 { 80 END_LONG_DOUBLE_ROUNDING (); 81 82 // It might be unused. 83 octave_unused_parameter (oldcw); 84 } 85