blob: 7058aa68ff0ea819ba39e8216009d5f80aceba26 [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001/* Test lgamma functions do not set signgam for ISO C.
2 Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>. */
18
19#undef _LIBC
20#undef _GNU_SOURCE
21#define _ISOMAC
22
23#include <math.h>
24#include <stdio.h>
25
26#define INITVAL ((TYPE) -1 / 3)
27
28#if DO_INIT
29TYPE signgam = INITVAL;
30#else
31TYPE signgam;
32#endif
33
34#define RUN_TESTS(FUNC, TYPE) \
35 do \
36 { \
37 volatile TYPE a, b, c __attribute__ ((unused)); \
38 a = 0.5; \
39 b = -0.5; \
40 signgam = INITVAL; \
41 c = FUNC (a); \
42 if (signgam == INITVAL) \
43 puts ("PASS: " #FUNC " (0.5) setting signgam"); \
44 else \
45 { \
46 puts ("FAIL: " #FUNC " (0.5) setting signgam"); \
47 result = 1; \
48 } \
49 signgam = INITVAL; \
50 c = FUNC (b); \
51 if (signgam == INITVAL) \
52 puts ("PASS: " #FUNC " (-0.5) setting signgam"); \
53 else \
54 { \
55 puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \
56 result = 1; \
57 } \
58 } \
59 while (0)
60
61int
62main (void)
63{
64 int result = 0;
65 RUN_TESTS (lgammaf, float);
66 RUN_TESTS (lgamma, double);
67#ifndef NO_LONG_DOUBLE
68 RUN_TESTS (lgammal, long double);
69#endif
70 return result;
71}