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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [machine/] [i386/] [f_llrint.c] - Blame information for rev 455

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 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
#ifdef __GNUC__
11
#if !defined(_SOFT_FLOAT)
12
 
13
#include <math.h>
14
 
15
/*
16
FUNCTION
17
<<llrint>>, <<llrintf>>, <<llrintl>>---round and convert to long long integer
18
INDEX
19
        llrint
20
INDEX
21
        llrintf
22
INDEX
23
        llrintl
24
 
25
ANSI_SYNOPSIS
26
        #include <math.h>
27
        long long int llrint(double x);
28
        long long int llrintf(float x);
29
        long long int llrintl(long double x);
30
 
31
TRAD_SYNOPSIS
32
        ANSI-only.
33
 
34
DESCRIPTION
35
The <<llrint>>, <<llrintf>> and <<llrintl>> functions round <[x]> to the nearest integer value,
36
according to the current rounding direction. If the rounded value is outside the
37
range of the return type, the numeric result is unspecified. A range error may
38
occur if the magnitude of <[x]> is too large.
39
 
40
RETURNS
41
These functions return the rounded integer value of <[x]>.
42
<<llrint>>, <<llrintf>> and <<llrintl>> return the result as a long long integer.
43
 
44
PORTABILITY
45
<<llrint>>, <<llrintf>> and <<llrintl>> are ANSI.
46
<<llrint>>, <<llrintf>> and <<llrintl>> are only available on i386 platforms when
47
hardware floating point support is available and when compiling with GCC.
48
 
49
*/
50
 
51
/*
52
 * Fast math version of llrint(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 long int _f_llrint (double x)
62
{
63
  long long int _result;
64
  asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st");
65
  return _result;
66
}
67
 
68
/* For now, we only have the fast math version.  */
69
long long int llrint (double x) {
70
  return _f_llrint(x);
71
}
72
 
73
#endif /* !_SOFT_FLOAT */
74
#endif /* __GNUC__ */

powered by: WebSVN 2.1.0

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