1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2006
21 * the Initial Developer. All Rights Reserved.
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
44 // todo need asm versions from Player
46 REALLY_INLINE
double MathUtils::abs(double value
)
51 REALLY_INLINE
double MathUtils::acos(double value
)
56 REALLY_INLINE
double MathUtils::asin(double value
)
61 REALLY_INLINE
double MathUtils::atan(double value
)
66 REALLY_INLINE
double MathUtils::atan2(double y
, double x
)
71 REALLY_INLINE
double MathUtils::ceil(double value
)
73 // MacOS X Intel 10.5 incorrectly make ceil(-0.5) -> 0.0 instead of -0.0
74 // special-case and correct.
75 #if defined(AVMPLUS_MAC) && (defined(AVMPLUS_IA32) || defined(AVMPLUS_AMD64))
76 double r
= ::ceil(value
);
77 if (r
== 0.0 && value
< 0.0) r
= -0.0;
84 REALLY_INLINE
double MathUtils::cos(double value
)
86 #if defined(VMCFG_TWEAK_SIN_COS_NONFINITE)
87 if (isNaN(value
) || isInfinite(value
))
93 REALLY_INLINE
double MathUtils::exp(double value
)
98 REALLY_INLINE
double MathUtils::floor(double value
)
100 return ::floor(value
);
103 REALLY_INLINE
uint64_t MathUtils::frexp(double value
, int *eptr
)
105 double fracMantissa
= ::frexp(value
, eptr
);
107 // correct mantissa and eptr to get integer values
109 *eptr
-= 53; // 52 mantissa bits + the hidden bit
110 return (uint64_t)(fracMantissa
* (double)(1LL << 53));
113 REALLY_INLINE
double MathUtils::log(double value
)
118 REALLY_INLINE
double MathUtils::mod(double x
, double y
)
123 REALLY_INLINE
double MathUtils::powInternal(double x
, double y
)
128 REALLY_INLINE
double MathUtils::sin(double value
)
130 #if defined(VMCFG_TWEAK_SIN_COS_NONFINITE)
131 if (isNaN(value
) || isInfinite(value
))
137 REALLY_INLINE
double MathUtils::sqrt(double value
)
139 return ::sqrt(value
);
142 REALLY_INLINE
double MathUtils::tan(double value
)