VirtualBox

source: vbox/trunk/include/iprt/nocrt/amd64/math.h@ 103224

Last change on this file since 103224 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.2 KB
Line 
1/** @file
2 * IPRT / No-CRT - math.h, AMD 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_amd64_math_h
37#define IPRT_INCLUDED_nocrt_amd64_math_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/asm.h>
43
44
45#if RT_INLINE_ASM_GNU_STYLE && defined(__SSE__)
46
47DECLINLINE(long double) inline_atan2l(long double lrd1, long double lrd2)
48{
49 long double lrdResult;
50 __asm__ __volatile__("fpatan"
51 : "=t" (lrdResult)
52 : "u" (lrd1),
53 "0" (lrd2)
54 : "st(1)");
55 return lrdResult;
56}
57
58DECLINLINE(long double) inline_rintl(long double lrd)
59{
60 long double lrdResult;
61 __asm__ __volatile__("frndint"
62 : "=t" (lrdResult)
63 : "0" (lrd));
64 return lrdResult;
65}
66
67DECLINLINE(float) inline_rintf(float rf)
68{
69 return (float)inline_rintl(rf);
70}
71
72DECLINLINE(double) inline_rint(double rd)
73{
74 return (double)inline_rintl(rd);
75}
76
77DECLINLINE(long double) inline_sqrtl(long double lrd)
78{
79 long double lrdResult;
80 __asm__ __volatile__("fsqrt"
81 : "=t" (lrdResult)
82 : "0" (lrd));
83 return lrdResult;
84}
85
86DECLINLINE(float) inline_sqrtf(float rf)
87{
88 return (float)inline_sqrtl(rf);
89}
90
91DECLINLINE(double) inline_sqrt(double rd)
92{
93 return (double)inline_sqrtl(rd);
94}
95
96
97# undef atan2l
98# define atan2l(lrd1, lrd2) inline_atan2l(lrd1, lrd2)
99# undef rint
100# define rint(rd) inline_rint(rd)
101# undef rintf
102# define rintf(rf) inline_rintf(rf)
103# undef rintl
104# define rintl(lrd) inline_rintl(lrd)
105# undef sqrt
106# define sqrt(rd) inline_sqrt(rd)
107# undef sqrtf
108# define sqrtf(rf) inline_sqrtf(rf)
109# undef sqrtl
110# define sqrtl(lrd) inline_sqrtl(lrd)
111
112#endif /* RT_INLINE_ASM_GNU_STYLE */
113
114#endif /* !IPRT_INCLUDED_nocrt_amd64_math_h */
115
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