source: trunk/src/libctests/glibc/math/test-tgmath-ret.c@ 2036

Last change on this file since 2036 was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
RevLine 
[2036]1/* Test compilation of tgmath macros.
2 Copyright (C) 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Jaeger <aj@suse.de>, 2003.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21#include <math.h>
22#include <complex.h>
23#include <tgmath.h>
24#include <stdio.h>
25
26static float fx;
27static double dx;
28static long double lx;
29static int errors = 0;
30
31static void
32our_error (const char *c)
33{
34 puts (c);
35 ++errors;
36}
37
38/* First function where the return type is constant. */
39
40#define CHECK_RET_CONST_TYPE(func, rettype, arg, name) \
41 if (sizeof (func (arg)) != sizeof (rettype)) \
42 our_error ("Return size of " #func " is wrong with " #name " argument");
43
44#define CHECK_RET_CONST_FLOAT(func, rettype) \
45 CHECK_RET_CONST_TYPE (func, rettype, fx, float)
46#define CHECK_RET_CONST_DOUBLE(func, rettype) \
47 CHECK_RET_CONST_TYPE (func, rettype, dx, double)
48#ifdef NO_LONG_DOUBLE
49# define CHECK_RET_CONST_LDOUBLE(func, rettype)
50#else
51# define CHECK_RET_CONST_LDOUBLE(func, rettype) \
52 CHECK_RET_CONST_TYPE (func, rettype, lx, long double)
53#endif
54
55#define CHECK_RET_CONST(func, rettype) \
56static void \
57check_return_ ##func (void) \
58{ \
59 CHECK_RET_CONST_FLOAT (func, rettype) \
60 CHECK_RET_CONST_DOUBLE (func, rettype) \
61 CHECK_RET_CONST_LDOUBLE (func, rettype) \
62}
63
64CHECK_RET_CONST(ilogb, int)
65CHECK_RET_CONST(lrint, long)
66CHECK_RET_CONST(lround, long)
67CHECK_RET_CONST(llrint, long long)
68CHECK_RET_CONST(llround, long long)
69
70static int
71do_test (void)
72{
73 check_return_ilogb ();
74 check_return_lrint ();
75 check_return_lround ();
76 check_return_llrint ();
77 check_return_llround ();
78
79 printf ("%Zd\n", sizeof(carg (lx)));
80
81 return errors != 0;
82}
83
84#define TEST_FUNCTION do_test ()
85#include "../test-skeleton.c"
Note: See TracBrowser for help on using the repository browser.