VirtualBox

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

Last change on this file since 98103 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.1 KB
Line 
1/** @file
2 * IPRT / No-CRT - math.h, x86 inlined functions.
3 */
4
5/*
6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_nocrt_x86_math_h
37#define IPRT_INCLUDED_nocrt_x86_math_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/asm.h>
43
44#if RT_INLINE_ASM_GNU_STYLE
45
46DECLINLINE(long double) inline_atan2l(long double lrd1, long double lrd2)
47{
48 long double lrdResult;
49 __asm__ __volatile__("fpatan"
50 : "=t" (lrdResult)
51 : "u" (lrd1),
52 "0" (lrd2)
53 : "st(1)");
54 return lrdResult;
55}
56
57DECLINLINE(long double) inline_rintl(long double lrd)
58{
59 long double lrdResult;
60 __asm__ __volatile__("frndint"
61 : "=t" (lrdResult)
62 : "0" (lrd));
63 return lrdResult;
64}
65
66DECLINLINE(float) inline_rintf(float rf)
67{
68 return (float)inline_rintl(rf);
69}
70
71DECLINLINE(double) inline_rint(double rd)
72{
73 return (double)inline_rintl(rd);
74}
75
76DECLINLINE(long double) inline_sqrtl(long double lrd)
77{
78 long double lrdResult;
79 __asm__ __volatile__("fsqrt"
80 : "=t" (lrdResult)
81 : "0" (lrd));
82 return lrdResult;
83}
84
85DECLINLINE(float) inline_sqrtf(float rf)
86{
87 return (float)inline_sqrtl(rf);
88}
89
90DECLINLINE(double) inline_sqrt(double rd)
91{
92 return (double)inline_sqrtl(rd);
93}
94
95
96# undef atan2l
97# define atan2l(lrd1, lrd2) inline_atan2l(lrd1, lrd2)
98# undef rint
99# define rint(rd) inline_rint(rd)
100# undef rintf
101# define rintf(rf) inline_rintf(rf)
102# undef rintl
103# define rintl(lrd) inline_rintl(lrd)
104# undef sqrt
105# define sqrt(rd) inline_sqrt(rd)
106# undef sqrtf
107# define sqrtf(rf) inline_sqrtf(rf)
108# undef sqrtl
109# define sqrtl(lrd) inline_sqrtl(lrd)
110
111#endif /* RT_INLINE_ASM_GNU_STYLE */
112
113#endif /* !IPRT_INCLUDED_nocrt_x86_math_h */
114
Note: See TracBrowser for help on using the repository browser.

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