VirtualBox

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

Last change on this file since 96354 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.8 KB
Line 
1/** @file
2 * IPRT / No-CRT - math.h, AMD inlined functions.
3 */
4
5/*
6 * Copyright (C) 2006-2022 Oracle Corporation
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 (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_nocrt_amd64_math_h
27#define IPRT_INCLUDED_nocrt_amd64_math_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/asm.h>
33
34
35#if RT_INLINE_ASM_GNU_STYLE && defined(__SSE__)
36
37DECLINLINE(long double) inline_atan2l(long double lrd1, long double lrd2)
38{
39 long double lrdResult;
40 __asm__ __volatile__("fpatan"
41 : "=t" (lrdResult)
42 : "u" (lrd1),
43 "0" (lrd2)
44 : "st(1)");
45 return lrdResult;
46}
47
48DECLINLINE(long double) inline_rintl(long double lrd)
49{
50 long double lrdResult;
51 __asm__ __volatile__("frndint"
52 : "=t" (lrdResult)
53 : "0" (lrd));
54 return lrdResult;
55}
56
57DECLINLINE(float) inline_rintf(float rf)
58{
59 return (float)inline_rintl(rf);
60}
61
62DECLINLINE(double) inline_rint(double rd)
63{
64 return (double)inline_rintl(rd);
65}
66
67DECLINLINE(long double) inline_sqrtl(long double lrd)
68{
69 long double lrdResult;
70 __asm__ __volatile__("fsqrt"
71 : "=t" (lrdResult)
72 : "0" (lrd));
73 return lrdResult;
74}
75
76DECLINLINE(float) inline_sqrtf(float rf)
77{
78 return (float)inline_sqrtl(rf);
79}
80
81DECLINLINE(double) inline_sqrt(double rd)
82{
83 return (double)inline_sqrtl(rd);
84}
85
86
87# undef atan2l
88# define atan2l(lrd1, lrd2) inline_atan2l(lrd1, lrd2)
89# undef rint
90# define rint(rd) inline_rint(rd)
91# undef rintf
92# define rintf(rf) inline_rintf(rf)
93# undef rintl
94# define rintl(lrd) inline_rintl(lrd)
95# undef sqrt
96# define sqrt(rd) inline_sqrt(rd)
97# undef sqrtf
98# define sqrtf(rf) inline_sqrtf(rf)
99# undef sqrtl
100# define sqrtl(lrd) inline_sqrtl(lrd)
101
102#endif /* RT_INLINE_ASM_GNU_STYLE */
103
104#endif /* !IPRT_INCLUDED_nocrt_amd64_math_h */
105
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