VirtualBox

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

Last change on this file since 76553 was 76553, checked in by vboxsync, 6 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, x86 inlined functions.
3 */
4
5/*
6 * Copyright (C) 2006-2019 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_nocrt_x86_math_h
27#define ___iprt_nocrt_x86_math_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/asm.h>
33
34#if RT_INLINE_ASM_GNU_STYLE
35
36DECLINLINE(long double) inline_atan2l(long double lrd1, long double lrd2)
37{
38 long double lrdResult;
39 __asm__ __volatile__("fpatan"
40 : "=t" (lrdResult)
41 : "u" (lrd1),
42 "0" (lrd2)
43 : "st(1)");
44 return lrdResult;
45}
46
47DECLINLINE(long double) inline_rintl(long double lrd)
48{
49 long double lrdResult;
50 __asm__ __volatile__("frndint"
51 : "=t" (lrdResult)
52 : "0" (lrd));
53 return lrdResult;
54}
55
56DECLINLINE(float) inline_rintf(float rf)
57{
58 return (float)inline_rintl(rf);
59}
60
61DECLINLINE(double) inline_rint(double rd)
62{
63 return (double)inline_rintl(rd);
64}
65
66DECLINLINE(long double) inline_sqrtl(long double lrd)
67{
68 long double lrdResult;
69 __asm__ __volatile__("fsqrt"
70 : "=t" (lrdResult)
71 : "0" (lrd));
72 return lrdResult;
73}
74
75DECLINLINE(float) inline_sqrtf(float rf)
76{
77 return (float)inline_sqrtl(rf);
78}
79
80DECLINLINE(double) inline_sqrt(double rd)
81{
82 return (double)inline_sqrtl(rd);
83}
84
85
86# undef atan2l
87# define atan2l(lrd1, lrd2) inline_atan2l(lrd1, lrd2)
88# undef rint
89# define rint(rd) inline_rint(rd)
90# undef rintf
91# define rintf(rf) inline_rintf(rf)
92# undef rintl
93# define rintl(lrd) inline_rintl(lrd)
94# undef sqrt
95# define sqrt(rd) inline_sqrt(rd)
96# undef sqrtf
97# define sqrtf(rf) inline_sqrtf(rf)
98# undef sqrtl
99# define sqrtl(lrd) inline_sqrtl(lrd)
100
101#endif /* RT_INLINE_ASM_GNU_STYLE */
102
103#endif
104
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