OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [machine/] [i386/] [f_lrint.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * ====================================================
3
 * x87 FP implementation contributed to Newlib by
4
 * Dave Korn, November 2007.  This file is placed in the
5
 * public domain.  Permission to use, copy, modify, and
6
 * distribute this software is freely granted.
7
 * ====================================================
8
 */
9
 
10
#if defined(__GNUC__) && !defined(_SOFT_FLOAT)
11
 
12
#include <math.h>
13
 
14
/*
15
FUNCTION
16
<<lrint>>, <<lrintf>>, <<lrintl>>---round and convert to long integer
17
INDEX
18
        lrint
19
INDEX
20
        lrintf
21
INDEX
22
        lrintl
23
 
24
ANSI_SYNOPSIS
25
        #include <math.h>
26
        long int lrint(double x);
27
        long int lrintf(float x);
28
        long int lrintl(long double x);
29
 
30
TRAD_SYNOPSIS
31
        ANSI-only.
32
 
33
DESCRIPTION
34
The <<lrint>>, <<lrintf>> and <<lrintl>> functions round <[x]> to the nearest integer value,
35
according to the current rounding direction. If the rounded value is outside the
36
range of the return type, the numeric result is unspecified. A range error may
37
occur if the magnitude of <[x]> is too large.
38
 
39
RETURNS
40
These functions return the rounded integer value of <[x]>.
41
<<lrint>>, <<lrintf>> and <<lrintl>> return the result as a long integer.
42
 
43
PORTABILITY
44
<<lrint>>, <<lrintf>>, and <<lrintl>> are ANSI.
45
<<lrint>> and <<lrintf>> are available on all platforms.
46
<<lrintl>> is only available on i386 platforms when hardware
47
floating point support is available and when compiling with GCC.
48
 
49
*/
50
 
51
/*
52
 * Fast math version of lrint(x)
53
 * Return x rounded to integral value according to the prevailing
54
 * rounding mode.
55
 * Method:
56
 *      Using inline x87 asms.
57
 * Exception:
58
 *      Governed by x87 FPCR.
59
 */
60
 
61
long int _f_lrint (double x)
62
{
63
  long int _result;
64
  asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st");
65
  return _result;
66
}
67
 
68
#endif  /* !__GNUC__ || _SOFT_FLOAT */
69
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.