Home | History | Annotate | Line # | Download | only in tools
      1 /* check_mparam - check a mparam.h file
      2 
      3 Copyright 2018-2023 Free Software Foundation, Inc.
      4 Contributed by the Arenaire and Caramel projects, INRIA.
      5 
      6 This program is free software; you can redistribute it and/or modify
      7 it under the terms of the GNU Lesser General Public License as published by
      8 the Free Software Foundation; either version 3 of the License, or (at your
      9 option) any later version.
     10 
     11 This program is distributed in the hope that it will be useful, but
     12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
     14 License for more details.
     15 
     16 You should have received a copy of the GNU Lesser General Public License
     17 along with this program; see the file COPYING.LESSER.  If not, see
     18 https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
     19 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
     20 
     21 /* To check some mparam.h tables:
     22    1) make a symbolic link to the corresponding mparam.h or
     23       provide -DMPARAM='"..."' with a path to the mparam.h
     24       file when compiling this program
     25    2) compile and run this program */
     26 
     27 #include <stdio.h>
     28 
     29 #ifndef MPARAM
     30 # define MPARAM "mparam.h"
     31 #endif
     32 
     33 #include MPARAM
     34 
     35 #define numberof_const(x)  (sizeof (x) / sizeof ((x)[0]))
     36 
     37 static short mulhigh_ktab[] = {MPFR_MULHIGH_TAB};
     38 #define MPFR_MULHIGH_TAB_SIZE (numberof_const (mulhigh_ktab))
     39 
     40 static short sqrhigh_ktab[] = {MPFR_SQRHIGH_TAB};
     41 #define MPFR_SQRHIGH_TAB_SIZE (numberof_const (sqrhigh_ktab))
     42 
     43 static short divhigh_ktab[] = {MPFR_DIVHIGH_TAB};
     44 #define MPFR_DIVHIGH_TAB_SIZE (numberof_const (divhigh_ktab))
     45 
     46 int main (void)
     47 {
     48   int err = 0, n;
     49 
     50   for (n = 0; n < MPFR_MULHIGH_TAB_SIZE; n++)
     51     if (mulhigh_ktab[n] >= n)
     52       {
     53         printf ("Error, mulhigh_ktab[%d] = %d\n", n, mulhigh_ktab[n]);
     54         err = 1;
     55       }
     56 
     57   for (n = 0; n < MPFR_SQRHIGH_TAB_SIZE; n++)
     58     if (sqrhigh_ktab[n] >= n)
     59       {
     60         printf ("Error, sqrhigh_ktab[%d] = %d\n", n, sqrhigh_ktab[n]);
     61         err = 1;
     62       }
     63 
     64   for (n = 2; n < MPFR_DIVHIGH_TAB_SIZE; n++)
     65     if (divhigh_ktab[n] >= n-1)
     66       {
     67         printf ("Error, divhigh_ktab[%d] = %d\n", n, divhigh_ktab[n]);
     68         err = 1;
     69       }
     70 
     71   return err;
     72 }
     73