1/* tbuildopt.c -- test file for mpfr_buildopt_tls_p and 2 mpfr_buildopt_decimal_p. 3 4Copyright 2009-2023 Free Software Foundation, Inc. 5Contributed by the AriC and Caramba projects, INRIA. 6 7This file is part of the GNU MPFR Library. 8 9The GNU MPFR Library is free software; you can redistribute it and/or modify 10it under the terms of the GNU Lesser General Public License as published by 11the Free Software Foundation; either version 3 of the License, or (at your 12option) any later version. 13 14The GNU MPFR Library is distributed in the hope that it will be useful, but 15WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17License for more details. 18 19You should have received a copy of the GNU Lesser General Public License 20along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 21https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2251 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ 23 24#include "mpfr-test.h" 25 26static void 27check_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 44static void 45check_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 62static void 63check_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 80static void 81check_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 98static void 99check_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 116int 117main (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