Back to index

glibc  2.9
test-tgmath-int.c
Go to the documentation of this file.
00001 /* Test compilation of tgmath macros.
00002    Copyright (C) 2005 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Andreas Jaeger <aj@suse.de>, 2005.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <math.h>
00022 #include <complex.h>
00023 #include <tgmath.h>
00024 #include <stdio.h>
00025 
00026 static int errors = 0;
00027 
00028 static void
00029 our_error (const char *c)
00030 {
00031   puts (c);
00032   ++errors;
00033 }
00034 
00035 #define CHECK_RET_CONST_TYPE(func, rettype, name)                     \
00036   if (sizeof (func) != sizeof (rettype))                       \
00037     our_error ("Return size of " #name " is " #func" wrong");
00038 
00039 #define CHECK_RET_CONST_FLOAT(func, name)        \
00040   CHECK_RET_CONST_TYPE (func, float, name)
00041 
00042 #define CHECK_RET_CONST_DOUBLE(func, name)              \
00043   CHECK_RET_CONST_TYPE (func, double, name)
00044 
00045 static int
00046 do_test (void)
00047 {
00048   int i;
00049   float f;
00050   double d;
00051 
00052   CHECK_RET_CONST_DOUBLE (sin (i), "sin (i)");
00053   CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
00054   CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
00055   CHECK_RET_CONST_DOUBLE (pow (i, f), "pow (i, f)");
00056   CHECK_RET_CONST_DOUBLE (pow (i, d), "pow (i, d)");
00057   CHECK_RET_CONST_DOUBLE (pow (f, i), "pow (f, i)");
00058   CHECK_RET_CONST_DOUBLE (pow (d, i), "pow (d, i)");
00059   CHECK_RET_CONST_DOUBLE (fma (i, i, i), "fma (i, i, i)");
00060   CHECK_RET_CONST_DOUBLE (fma (f, i, i), "fma (f, i, i)");
00061   CHECK_RET_CONST_DOUBLE (fma (i, f, i), "fma (i, f, i)");
00062   CHECK_RET_CONST_DOUBLE (fma (i, i, f), "fma (i, i, f)");
00063   CHECK_RET_CONST_DOUBLE (fma (d, i, i), "fma (d, i, i)");
00064   CHECK_RET_CONST_DOUBLE (fma (i, d, i), "fma (i, d, i)");
00065   CHECK_RET_CONST_DOUBLE (fma (i, i, d), "fma (i, i, d)");
00066 
00067   return errors != 0;
00068 }
00069 
00070 #define TEST_FUNCTION do_test ()
00071 #include "../test-skeleton.c"