Line data Source code
1 : /* Definitions of floating-point conversion from compiler
2 : internal format to MPFR.
3 : Copyright (C) 2010-2026 Free Software Foundation, Inc.
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 : #ifndef GCC_REALGMP_H
22 : #define GCC_REALGMP_H
23 :
24 : #include <mpfr.h>
25 : #include <mpc.h>
26 :
27 : class auto_mpfr
28 : {
29 : public:
30 : auto_mpfr () { mpfr_init (m_mpfr); }
31 4182970 : explicit auto_mpfr (mpfr_prec_t prec) { mpfr_init2 (m_mpfr, prec); }
32 4182970 : ~auto_mpfr () { mpfr_clear (m_mpfr); }
33 :
34 8386982 : operator mpfr_t& () { return m_mpfr; }
35 : mpfr_ptr operator-> () { return m_mpfr; }
36 :
37 : auto_mpfr (const auto_mpfr &) = delete;
38 : auto_mpfr &operator= (const auto_mpfr &) = delete;
39 :
40 : #if GCC_VERSION < 4008 || GCC_VERSION >= 5000
41 : /* GCC 4.8 and 4.9 don't support this, only fixed in PR62101 for 5.0. */
42 : friend void mpfr_clear (auto_mpfr&) = delete;
43 : friend void mpfr_init (auto_mpfr&) = delete;
44 : friend void mpfr_init2 (auto_mpfr&, mpfr_prec_t) = delete;
45 : #endif
46 :
47 : private:
48 : mpfr_t m_mpfr;
49 : };
50 :
51 : /* Convert between MPFR and REAL_VALUE_TYPE. The caller is
52 : responsible for initializing and clearing the MPFR parameter. */
53 :
54 : extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr, tree, mpfr_rnd_t);
55 : extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr,
56 : const real_format *, mpfr_rnd_t);
57 : extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mpfr_rnd_t);
58 :
59 : #endif /* ! GCC_REALGMP_H */
|