Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
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 |
||
14 | |||
15 | /* |
||
16 | FUNCTION |
||
17 | < |
||
18 | INDEX |
||
19 | llrint |
||
20 | INDEX |
||
21 | llrintf |
||
22 | INDEX |
||
23 | llrintl |
||
24 | |||
25 | ANSI_SYNOPSIS |
||
26 | #include |
||
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 < |
||
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 | < |
||
43 | |||
44 | PORTABILITY |
||
45 | < |
||
46 | The fast math versions of < |
||
47 | available on i386 platforms when hardware floating point support is available |
||
48 | and when compiling with GCC. |
||
49 | |||
50 | */ |
||
51 | |||
52 | /* |
||
53 | * Fast math version of llrint(x) |
||
54 | * Return x rounded to integral value according to the prevailing |
||
55 | * rounding mode. |
||
56 | * Method: |
||
57 | * Using inline x87 asms. |
||
58 | * Exception: |
||
59 | * Governed by x87 FPCR. |
||
60 | */ |
||
61 | |||
62 | long long int _f_llrint (double x) |
||
63 | { |
||
64 | long long int _result; |
||
65 | asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st"); |
||
66 | return _result; |
||
67 | } |
||
68 | |||
69 | #endif /* !_SOFT_FLOAT */ |
||
70 | #endif /* __GNUC__ */ |