xref: /rk3399_rockchip-uboot/post/lib_powerpc/fpu/980619-1.c (revision 326ea986ac150acdc7656d57fca647db80b50158)
1a47a12beSStefan Roese /*
2a47a12beSStefan Roese  * Copyright (C) 2007
3a47a12beSStefan Roese  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4a47a12beSStefan Roese  *
5*1a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
6a47a12beSStefan Roese  */
7a47a12beSStefan Roese /*
8a47a12beSStefan Roese  * This file is originally a part of the GCC testsuite.
9a47a12beSStefan Roese  */
10a47a12beSStefan Roese 
11a47a12beSStefan Roese #include <common.h>
12a47a12beSStefan Roese 
13a47a12beSStefan Roese #include <post.h>
14a47a12beSStefan Roese 
15a47a12beSStefan Roese GNU_FPOST_ATTR
16a47a12beSStefan Roese 
17e009cdebSKumar Gala #if CONFIG_POST & CONFIG_SYS_POST_FPU
18e009cdebSKumar Gala 
fpu_post_test_math4(void)19a47a12beSStefan Roese int fpu_post_test_math4 (void)
20a47a12beSStefan Roese {
21a47a12beSStefan Roese 	volatile float reale = 1.0f;
22a47a12beSStefan Roese 	volatile float oneplus;
23a47a12beSStefan Roese 	int i;
24a47a12beSStefan Roese 
25a47a12beSStefan Roese 	if (sizeof (float) != 4)
26a47a12beSStefan Roese 		return 0;
27a47a12beSStefan Roese 
28a47a12beSStefan Roese 	for (i = 0; ; i++)
29a47a12beSStefan Roese 	{
30a47a12beSStefan Roese 		oneplus = 1.0f + reale;
31a47a12beSStefan Roese 		if (oneplus == 1.0f)
32a47a12beSStefan Roese 			break;
33a47a12beSStefan Roese 		reale = reale / 2.0f;
34a47a12beSStefan Roese 	}
35a47a12beSStefan Roese 	/* Assumes ieee754 accurate arithmetic above.  */
36a47a12beSStefan Roese 	if (i != 24) {
37a47a12beSStefan Roese 		post_log ("Error in FPU math4 test\n");
38a47a12beSStefan Roese 		return -1;
39a47a12beSStefan Roese 	}
40a47a12beSStefan Roese 	return 0;
41a47a12beSStefan Roese }
42a47a12beSStefan Roese 
43a47a12beSStefan Roese #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
44