xref: /titanic_51/usr/src/lib/libast/common/port/astmath.c (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin *                                                                      *
3da2e3ebdSchin *               This software is part of the ast package               *
4*3e14f97fSRoger A. Faulkner *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
5da2e3ebdSchin *                      and is licensed under the                       *
6da2e3ebdSchin *                  Common Public License, Version 1.0                  *
77c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
8da2e3ebdSchin *                                                                      *
9da2e3ebdSchin *                A copy of the License is available at                 *
10da2e3ebdSchin *            http://www.opensource.org/licenses/cpl1.0.txt             *
11da2e3ebdSchin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12da2e3ebdSchin *                                                                      *
13da2e3ebdSchin *              Information and Software Systems Research               *
14da2e3ebdSchin *                            AT&T Research                             *
15da2e3ebdSchin *                           Florham Park NJ                            *
16da2e3ebdSchin *                                                                      *
17da2e3ebdSchin *                 Glenn Fowler <gsf@research.att.com>                  *
18da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
19da2e3ebdSchin *                   Phong Vo <kpv@research.att.com>                    *
20da2e3ebdSchin *                                                                      *
21da2e3ebdSchin ***********************************************************************/
22da2e3ebdSchin /*
23da2e3ebdSchin  * used to test if -last requires -lm
24da2e3ebdSchin  *
25da2e3ebdSchin  *	arch		-last			-lm
26da2e3ebdSchin  *	----		-----			---
27da2e3ebdSchin  *	linux.sparc	sfdlen,sfputd		frexp,ldexp
28da2e3ebdSchin  */
29da2e3ebdSchin 
307c2fbfb3SApril Chin #if N >= 8
317c2fbfb3SApril Chin #define _ISOC99_SOURCE	1
327c2fbfb3SApril Chin #endif
337c2fbfb3SApril Chin 
34da2e3ebdSchin #include <math.h>
35da2e3ebdSchin 
36da2e3ebdSchin int
main()37da2e3ebdSchin main()
38da2e3ebdSchin {
39da2e3ebdSchin #if N & 1
40da2e3ebdSchin 	long double	value = 0;
41da2e3ebdSchin #else
42da2e3ebdSchin 	double		value = 0;
43da2e3ebdSchin #endif
44da2e3ebdSchin #if N < 5
45da2e3ebdSchin 	int		exp = 0;
46da2e3ebdSchin #endif
47da2e3ebdSchin 
48da2e3ebdSchin #if N == 1
49da2e3ebdSchin 	return ldexpl(value, exp) != 0;
50da2e3ebdSchin #endif
51da2e3ebdSchin #if N == 2
52da2e3ebdSchin 	return ldexp(value, exp) != 0;
53da2e3ebdSchin #endif
54da2e3ebdSchin #if N == 3
55da2e3ebdSchin 	return frexpl(value, &exp) != 0;
56da2e3ebdSchin #endif
57da2e3ebdSchin #if N == 4
58da2e3ebdSchin 	return frexp(value, &exp) != 0;
59da2e3ebdSchin #endif
60da2e3ebdSchin #if N == 5
61da2e3ebdSchin 	return isnan(value);
62da2e3ebdSchin #endif
63da2e3ebdSchin #if N == 6
64da2e3ebdSchin 	return isnan(value);
65da2e3ebdSchin #endif
667c2fbfb3SApril Chin #if N == 7
677c2fbfb3SApril Chin 	return copysign(1.0, value) < 0;
687c2fbfb3SApril Chin #endif
697c2fbfb3SApril Chin #if N == 8
707c2fbfb3SApril Chin 	return signbit(value);
717c2fbfb3SApril Chin #endif
72da2e3ebdSchin }
73