]> git.ipfire.org Git - thirdparty/glibc.git/blob - math/test-signgam-finite-c99.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / math / test-signgam-finite-c99.c
1 /* Test lgamma functions do not set signgam for -ffinite-math-only for ISO C.
2 Copyright (C) 2015-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #undef _LIBC
20 #undef __LIBC_INTERNAL_MATH_INLINES
21 #undef _GNU_SOURCE
22
23 #include <math.h>
24 #include <stdio.h>
25
26 int signgam;
27
28 #define RUN_TESTS(FUNC, TYPE) \
29 do \
30 { \
31 volatile TYPE a, b, c __attribute__ ((unused)); \
32 a = 0.5; \
33 b = -0.5; \
34 signgam = 123; \
35 c = FUNC (a); \
36 if (signgam == 123) \
37 puts ("PASS: " #FUNC " (0.5) setting signgam"); \
38 else \
39 { \
40 puts ("FAIL: " #FUNC " (0.5) setting signgam"); \
41 result = 1; \
42 } \
43 signgam = 123; \
44 c = FUNC (b); \
45 if (signgam == 123) \
46 puts ("PASS: " #FUNC " (-0.5) setting signgam"); \
47 else \
48 { \
49 puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \
50 result = 1; \
51 } \
52 } \
53 while (0)
54
55 int
56 main (void)
57 {
58 int result = 0;
59 RUN_TESTS (lgammaf, float);
60 RUN_TESTS (lgamma, double);
61 RUN_TESTS (lgammal, long double);
62 return result;
63 }