1 | /** @file
|
---|
2 | * innotek Portable Runtime / No-CRT - math.h, AMD inlined functions.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ___iprt_nocrt_amd64_math_h
|
---|
18 | #define ___iprt_nocrt_amd64_math_h
|
---|
19 |
|
---|
20 | #include <iprt/asm.h>
|
---|
21 |
|
---|
22 |
|
---|
23 | #if RT_INLINE_ASM_GNU_STYLE
|
---|
24 |
|
---|
25 | DECLINLINE(long double) inline_atan2l(long double lrd1, long double lrd2)
|
---|
26 | {
|
---|
27 | long double lrdResult;
|
---|
28 | __asm__ __volatile__("fpatan"
|
---|
29 | : "=t" (lrdResult)
|
---|
30 | : "u" (lrd1),
|
---|
31 | "0" (lrd2)
|
---|
32 | : "st(1)");
|
---|
33 | return lrdResult;
|
---|
34 | }
|
---|
35 |
|
---|
36 | DECLINLINE(long double) inline_rintl(long double lrd)
|
---|
37 | {
|
---|
38 | long double lrdResult;
|
---|
39 | __asm__ __volatile__("frndint"
|
---|
40 | : "=t" (lrdResult)
|
---|
41 | : "0" (lrd));
|
---|
42 | return lrdResult;
|
---|
43 | }
|
---|
44 |
|
---|
45 | DECLINLINE(float) inline_rintf(float rf)
|
---|
46 | {
|
---|
47 | return (float)inline_rintl(rf);
|
---|
48 | }
|
---|
49 |
|
---|
50 | DECLINLINE(double) inline_rint(double rd)
|
---|
51 | {
|
---|
52 | return (double)inline_rintl(rd);
|
---|
53 | }
|
---|
54 |
|
---|
55 | DECLINLINE(long double) inline_sqrtl(long double lrd)
|
---|
56 | {
|
---|
57 | long double lrdResult;
|
---|
58 | __asm__ __volatile__("fsqrt"
|
---|
59 | : "=t" (lrdResult)
|
---|
60 | : "0" (lrd));
|
---|
61 | return lrdResult;
|
---|
62 | }
|
---|
63 |
|
---|
64 | DECLINLINE(float) inline_sqrtf(float rf)
|
---|
65 | {
|
---|
66 | return (float)inline_sqrtl(rf);
|
---|
67 | }
|
---|
68 |
|
---|
69 | DECLINLINE(double) inline_sqrt(double rd)
|
---|
70 | {
|
---|
71 | return (double)inline_sqrt(rd);
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | # undef atan2l
|
---|
76 | # define atan2l(lrd1, lrd2) inline_atan2l(lrd1, lrd2)
|
---|
77 | # undef rint
|
---|
78 | # define rint(rd) inline_rint(rd)
|
---|
79 | # undef rintf
|
---|
80 | # define rintf(rf) inline_rintf(rf)
|
---|
81 | # undef rintl
|
---|
82 | # define rintl(lrd) inline_rintl(lrd)
|
---|
83 | # undef sqrt
|
---|
84 | # define sqrt(rd) inline_sqrt(rd)
|
---|
85 | # undef sqrtf
|
---|
86 | # define sqrtf(rf) inline_sqrtf(rf)
|
---|
87 | # undef sqrtl
|
---|
88 | # define sqrtl(lrd) inline_sqrtl(lrd)
|
---|
89 |
|
---|
90 | #endif /* RT_INLINE_ASM_GNU_STYLE */
|
---|
91 |
|
---|
92 | #endif
|
---|
93 |
|
---|