| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Test lgamma functions do not set signgam for -ffinite-math-only 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 | #undef _Mlong_double_ | 
|  | 22 | #define _ISOMAC | 
|  | 23 |  | 
|  | 24 | #include <math.h> | 
|  | 25 | #include <stdio.h> | 
|  | 26 |  | 
|  | 27 | int signgam; | 
|  | 28 |  | 
|  | 29 | #define RUN_TESTS(FUNC, TYPE)					\ | 
|  | 30 | do								\ | 
|  | 31 | {								\ | 
|  | 32 | volatile TYPE a, b, c __attribute__ ((unused));		\ | 
|  | 33 | a = 0.5;							\ | 
|  | 34 | b = -0.5;							\ | 
|  | 35 | signgam = 123;						\ | 
|  | 36 | c = FUNC (a);						\ | 
|  | 37 | if (signgam == 123)					\ | 
|  | 38 | puts ("PASS: " #FUNC " (0.5) setting signgam");		\ | 
|  | 39 | else							\ | 
|  | 40 | {							\ | 
|  | 41 | puts ("FAIL: " #FUNC " (0.5) setting signgam");	\ | 
|  | 42 | result = 1;						\ | 
|  | 43 | }							\ | 
|  | 44 | signgam = 123;						\ | 
|  | 45 | c = FUNC (b);						\ | 
|  | 46 | if (signgam == 123)					\ | 
|  | 47 | puts ("PASS: " #FUNC " (-0.5) setting signgam");	\ | 
|  | 48 | else							\ | 
|  | 49 | {							\ | 
|  | 50 | puts ("FAIL: " #FUNC " (-0.5) setting signgam");	\ | 
|  | 51 | result = 1;						\ | 
|  | 52 | }							\ | 
|  | 53 | }								\ | 
|  | 54 | while (0) | 
|  | 55 |  | 
|  | 56 | int | 
|  | 57 | main (void) | 
|  | 58 | { | 
|  | 59 | int result = 0; | 
|  | 60 | RUN_TESTS (lgammaf, float); | 
|  | 61 | RUN_TESTS (lgamma, double); | 
|  | 62 | #ifndef NO_LONG_DOUBLE | 
|  | 63 | RUN_TESTS (lgammal, long double); | 
|  | 64 | #endif | 
|  | 65 | return result; | 
|  | 66 | } |