xref: /netbsd-src/external/lgpl3/mpfr/dist/src/mpfr-intmax.h (revision 154bfe8e089c1a0a4e9ed8414f08d3da90949162)
1 /* MPFR internal header related to intmax_t.
2 
3 Copyright 2004-2018 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramba projects, INRIA.
5 
6 This file is part of the GNU MPFR Library.
7 
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 
23 #ifndef __MPFR_INTMAX_H__
24 #define __MPFR_INTMAX_H__
25 
26 /* The ISO C99 standard specifies that in C++ implementations the
27  * INTMAX_MAX, ... macros should only be defined if explicitly requested.
28  */
29 #if defined __cplusplus
30 # define __STDC_LIMIT_MACROS
31 # define __STDC_CONSTANT_MACROS
32 #endif
33 
34 /* The definition of MPFR_USE_INTMAX_T is needed on systems for which
35  * the current (non-standard) macro tests in mpfr.h is not sufficient.
36  * This will force the support of intmax_t/uintmax_t if <inttypes.h>
37  * and/or <stdint.h> are available. This also avoids a failure in the
38  * tests (replace the macro tests in mpfr.h by just
39  *   #if defined (MPFR_USE_INTMAX_T)
40  * to simulate such a system and reproduce the problem).
41  * Note: if this makes the build fail on some systems (because these
42  * headers are broken), we will need a configure test to undefine
43  * HAVE_INTTYPES_H and HAVE_STDINT_H in such a case.
44  */
45 
46 #if HAVE_INTTYPES_H
47 # include <inttypes.h>
48 # define MPFR_USE_INTMAX_T
49 #endif
50 
51 #if HAVE_STDINT_H
52 # include <stdint.h>
53 # define MPFR_USE_INTMAX_T
54 #endif
55 
56 /* Largest signed integer type available for the MPFR build. */
57 #if defined(MPFR_USE_INTMAX_T)
58 typedef intmax_t mpfr_intmax_t;
59 typedef uintmax_t mpfr_uintmax_t;
60 #elif defined(HAVE_LONG_LONG)
61 typedef long long mpfr_intmax_t;
62 typedef unsigned long long mpfr_uintmax_t;
63 # define MPFR_INTMAX_MAX LLONG_MAX
64 #else
65 typedef long mpfr_intmax_t;
66 typedef unsigned long mpfr_uintmax_t;
67 # define MPFR_INTMAX_MAX LONG_MAX
68 #endif
69 
70 #endif
71