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