1*a47a12beSStefan Roese /* 2*a47a12beSStefan Roese * Copyright (C) 2007 3*a47a12beSStefan Roese * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4*a47a12beSStefan Roese * 5*a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this 6*a47a12beSStefan Roese * project. 7*a47a12beSStefan Roese * 8*a47a12beSStefan Roese * This program is free software; you can redistribute it and/or 9*a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as 10*a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of 11*a47a12beSStefan Roese * the License, or (at your option) any later version. 12*a47a12beSStefan Roese * 13*a47a12beSStefan Roese * This program is distributed in the hope that it will be useful, 14*a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 15*a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*a47a12beSStefan Roese * GNU General Public License for more details. 17*a47a12beSStefan Roese * 18*a47a12beSStefan Roese * You should have received a copy of the GNU General Public License 19*a47a12beSStefan Roese * along with this program; if not, write to the Free Software 20*a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21*a47a12beSStefan Roese * MA 02111-1307 USA 22*a47a12beSStefan Roese */ 23*a47a12beSStefan Roese /* 24*a47a12beSStefan Roese * This file is originally a part of the GCC testsuite. 25*a47a12beSStefan Roese */ 26*a47a12beSStefan Roese 27*a47a12beSStefan Roese #include <common.h> 28*a47a12beSStefan Roese 29*a47a12beSStefan Roese #include <post.h> 30*a47a12beSStefan Roese 31*a47a12beSStefan Roese #if CONFIG_POST & CONFIG_SYS_POST_FPU 32*a47a12beSStefan Roese 33*a47a12beSStefan Roese GNU_FPOST_ATTR 34*a47a12beSStefan Roese 35*a47a12beSStefan Roese static float rintf (float x) 36*a47a12beSStefan Roese { 37*a47a12beSStefan Roese volatile float TWO23 = 8388608.0; 38*a47a12beSStefan Roese 39*a47a12beSStefan Roese if (__builtin_fabs (x) < TWO23) 40*a47a12beSStefan Roese { 41*a47a12beSStefan Roese if (x > 0.0) 42*a47a12beSStefan Roese { 43*a47a12beSStefan Roese x += TWO23; 44*a47a12beSStefan Roese x -= TWO23; 45*a47a12beSStefan Roese } 46*a47a12beSStefan Roese else if (x < 0.0) 47*a47a12beSStefan Roese { 48*a47a12beSStefan Roese x = TWO23 - x; 49*a47a12beSStefan Roese x = -(x - TWO23); 50*a47a12beSStefan Roese } 51*a47a12beSStefan Roese } 52*a47a12beSStefan Roese 53*a47a12beSStefan Roese return x; 54*a47a12beSStefan Roese } 55*a47a12beSStefan Roese 56*a47a12beSStefan Roese int fpu_post_test_math2 (void) 57*a47a12beSStefan Roese { 58*a47a12beSStefan Roese if (rintf (-1.5) != -2.0) { 59*a47a12beSStefan Roese post_log ("Error in FPU math2 test\n"); 60*a47a12beSStefan Roese return -1; 61*a47a12beSStefan Roese } 62*a47a12beSStefan Roese return 0; 63*a47a12beSStefan Roese } 64*a47a12beSStefan Roese 65*a47a12beSStefan Roese #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */ 66