VirtualBox

source: vbox/trunk/include/iprt/nocrt/x86/math.h@ 3631

Last change on this file since 3631 was 3631, checked in by vboxsync, 18 years ago

iprt_hdr_h -> _iprt_hdr_h

File size: 2.6 KB
Line 
1/** @file
2 * innotek Portable Runtime / No-CRT - math.h, x86 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 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef ___iprt_nocrt_x86_math_h
22#define ___iprt_nocrt_x86_math_h
23
24#include <iprt/asm.h>
25
26#if RT_INLINE_ASM_GNU_STYLE
27
28DECLINLINE(long double) inline_atan2l(long double lrd1, long double lrd2)
29{
30 long double lrdResult;
31 __asm__ __volatile__("fpatan"
32 : "=t" (lrdResult)
33 : "u" (lrd1),
34 "0" (lrd2)
35 : "st(1)");
36 return lrdResult;
37}
38
39DECLINLINE(long double) inline_rintl(long double lrd)
40{
41 long double lrdResult;
42 __asm__ __volatile__("frndint"
43 : "=t" (lrdResult)
44 : "0" (lrd));
45 return lrdResult;
46}
47
48DECLINLINE(float) inline_rintf(float rf)
49{
50 return (float)inline_rintl(rf);
51}
52
53DECLINLINE(double) inline_rint(double rd)
54{
55 return (double)inline_rintl(rd);
56}
57
58DECLINLINE(long double) inline_sqrtl(long double lrd)
59{
60 long double lrdResult;
61 __asm__ __volatile__("fsqrt"
62 : "=t" (lrdResult)
63 : "0" (lrd));
64 return lrdResult;
65}
66
67DECLINLINE(float) inline_sqrtf(float rf)
68{
69 return (float)inline_sqrtl(rf);
70}
71
72DECLINLINE(double) inline_sqrt(double rd)
73{
74 return (double)inline_sqrt(rd);
75}
76
77
78# undef atan2l
79# define atan2l(lrd1, lrd2) inline_atan2l(lrd1, lrd2)
80# undef rint
81# define rint(rd) inline_rint(rd)
82# undef rintf
83# define rintf(rf) inline_rintf(rf)
84# undef rintl
85# define rintl(lrd) inline_rintl(lrd)
86# undef sqrt
87# define sqrt(rd) inline_sqrt(rd)
88# undef sqrtf
89# define sqrtf(rf) inline_sqrtf(rf)
90# undef sqrtl
91# define sqrtl(lrd) inline_sqrtl(lrd)
92
93#endif /* RT_INLINE_ASM_GNU_STYLE */
94
95#endif
96
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette