xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/tbuildopt.c (revision ba125506a622fe649968631a56eba5d42ff57863)
1 /* tbuildopt.c -- test file for mpfr_buildopt_tls_p and
2    mpfr_buildopt_decimal_p.
3 
4 Copyright 2009-2023 Free Software Foundation, Inc.
5 Contributed by the AriC and Caramba projects, INRIA.
6 
7 This file is part of the GNU MPFR Library.
8 
9 The GNU MPFR Library is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 The GNU MPFR Library is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17 License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public License
20 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
21 https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
22 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
23 
24 #include "mpfr-test.h"
25 
26 static void
check_tls_p(void)27 check_tls_p (void)
28 {
29 #ifdef MPFR_USE_THREAD_SAFE
30   if (!mpfr_buildopt_tls_p())
31     {
32       printf ("Error: mpfr_buildopt_tls_p should return true\n");
33       exit (1);
34     }
35 #else
36   if (mpfr_buildopt_tls_p())
37     {
38       printf ("Error: mpfr_buildopt_tls_p should return false\n");
39       exit (1);
40     }
41 #endif
42 }
43 
44 static void
check_decimal_p(void)45 check_decimal_p (void)
46 {
47 #ifdef MPFR_WANT_DECIMAL_FLOATS
48   if (!mpfr_buildopt_decimal_p())
49     {
50       printf ("Error: mpfr_buildopt_decimal_p should return true\n");
51       exit (1);
52     }
53 #else
54   if (mpfr_buildopt_decimal_p())
55     {
56       printf ("Error: mpfr_buildopt_decimal_p should return false\n");
57       exit (1);
58     }
59 #endif
60 }
61 
62 static void
check_float128_p(void)63 check_float128_p (void)
64 {
65 #ifdef MPFR_WANT_FLOAT128
66   if (!mpfr_buildopt_float128_p())
67     {
68       printf ("Error: mpfr_buildopt_float128_p should return true\n");
69       exit (1);
70     }
71 #else
72   if (mpfr_buildopt_float128_p())
73     {
74       printf ("Error: mpfr_buildopt_float128_p should return false\n");
75       exit (1);
76     }
77 #endif
78 }
79 
80 static void
check_gmpinternals_p(void)81 check_gmpinternals_p (void)
82 {
83 #if defined(MPFR_HAVE_GMP_IMPL) || defined(WANT_GMP_INTERNALS)
84   if (!mpfr_buildopt_gmpinternals_p())
85     {
86       printf ("Error: mpfr_buildopt_gmpinternals_p should return true\n");
87       exit (1);
88     }
89 #else
90   if (mpfr_buildopt_gmpinternals_p())
91     {
92       printf ("Error: mpfr_buildopt_gmpinternals_p should return false\n");
93       exit (1);
94     }
95 #endif
96 }
97 
98 static void
check_sharedcache_p(void)99 check_sharedcache_p (void)
100 {
101 #if defined(MPFR_WANT_SHARED_CACHE)
102   if (!mpfr_buildopt_sharedcache_p ())
103     {
104       printf ("Error: mpfr_buildopt_sharedcache_p should return true\n");
105       exit (1);
106     }
107 #else
108   if (mpfr_buildopt_sharedcache_p ())
109     {
110       printf ("Error: mpfr_buildopt_sharedcache_p should return false\n");
111       exit (1);
112     }
113 #endif
114 }
115 
116 int
main(void)117 main (void)
118 {
119   tests_start_mpfr ();
120 
121   check_tls_p();
122   check_decimal_p();
123   check_float128_p();
124   check_gmpinternals_p();
125   check_sharedcache_p ();
126   {
127     const char *s = mpfr_buildopt_tune_case ();
128     (void) strlen (s);
129   }
130 
131   tests_end_mpfr ();
132   return 0;
133 }
134