xref: /illumos-gate/usr/src/tools/smatch/src/validation/expand/builtin_fpclassify.c (revision c85f09cc92abd00c84e58ec9f0f5d942906cb713)
1*c85f09ccSJohn Levon enum { FP_NAN, FP_INF, FP_NOR, FP_SUB, FP_ZERO };
2*c85f09ccSJohn Levon 
3*c85f09ccSJohn Levon #define	classify(X) __builtin_fpclassify(FP_NAN,FP_INF,FP_NOR,FP_SUB,FP_ZERO,X)
4*c85f09ccSJohn Levon 
test(void)5*c85f09ccSJohn Levon int test(void)
6*c85f09ccSJohn Levon {
7*c85f09ccSJohn Levon 	if (classify(__builtin_nan("0")) != FP_NAN)
8*c85f09ccSJohn Levon 		return 0;
9*c85f09ccSJohn Levon 	if (classify(__builtin_inf("0")) != FP_INF)
10*c85f09ccSJohn Levon 		return 0;
11*c85f09ccSJohn Levon 	if (classify(1.0) != FP_NOR)
12*c85f09ccSJohn Levon 		return 0;
13*c85f09ccSJohn Levon 	if (classify(0.0) != FP_ZERO)
14*c85f09ccSJohn Levon 		return 0;
15*c85f09ccSJohn Levon 
16*c85f09ccSJohn Levon 	return 1;
17*c85f09ccSJohn Levon }
18*c85f09ccSJohn Levon 
19*c85f09ccSJohn Levon /*
20*c85f09ccSJohn Levon  * check-name: builtin_fpclassify
21*c85f09ccSJohn Levon  * check-command: test-linearize -Wno-decl $file
22*c85f09ccSJohn Levon  * check-known-to-fail
23*c85f09ccSJohn Levon  *
24*c85f09ccSJohn Levon  * check-output-ignore
25*c85f09ccSJohn Levon  * check-output-contains: ret\\..*\\$1
26*c85f09ccSJohn Levon  */
27