blob: 01bac500383651f725643fb7370b33e80adaca64 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sergei Poselenov3190dbe2007-07-05 08:17:37 +02002/*
3 * Copyright (C) 2007
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Sergei Poselenov3190dbe2007-07-05 08:17:37 +02005 */
6/*
7 * This file is originally a part of the GCC testsuite.
8 */
9
10#include <common.h>
11
Sergei Poselenov3190dbe2007-07-05 08:17:37 +020012#include <post.h>
13
Yuri Tikhonov7ed66f72008-12-20 14:54:21 +030014GNU_FPOST_ATTR
15
Tom Rini3dd5d4a2022-12-04 10:14:17 -050016#if CFG_POST & CFG_SYS_POST_FPU
Kumar Galafe6555b2011-01-25 03:00:08 -060017
Sergei Poselenov3190dbe2007-07-05 08:17:37 +020018static float rintf (float x)
19{
20 volatile float TWO23 = 8388608.0;
21
22 if (__builtin_fabs (x) < TWO23)
23 {
24 if (x > 0.0)
25 {
26 x += TWO23;
27 x -= TWO23;
28 }
29 else if (x < 0.0)
30 {
31 x = TWO23 - x;
32 x = -(x - TWO23);
33 }
34 }
35
36 return x;
37}
38
39int fpu_post_test_math2 (void)
40{
41 if (rintf (-1.5) != -2.0) {
42 post_log ("Error in FPU math2 test\n");
43 return -1;
44 }
45 return 0;
46}
47
Tom Rini3dd5d4a2022-12-04 10:14:17 -050048#endif /* CFG_POST & CFG_SYS_POST_FPU */