1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
20 /********************************************************************20**
22 Name: common MATH library functions
26 Desc: Common functions that are implemented in
27 a portable manner. These functions are selected
28 based on the operating system.
32 *********************************************************************21*/
35 /* header include files (.h) */
36 #include "envopt.h" /* environment options */
37 #include "envdep.h" /* environment dependent */
38 #include "envind.h" /* environment independent */
39 #include "gen.h" /* general */
40 #include "ssi.h" /* system services interface */
51 * Desc: common primitive for an absolute value of an integer
53 * Ret: absolute value of the operand
60 uint32_t cmAbs(F64 val)
62 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
63 return ((uint32_t) abs((int) val));/* G++ */
74 * Desc: common primitive for computing the power of x raised to y.
76 * Ret: value of x raised to the power of y.
83 F64 cmPow(F64 x,F64 y)
85 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
86 return ((F64) pow((F64)x, (F64)y));
96 * Desc: common primitive for computing the largest integral value
99 * Ret: floor value of x
108 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
109 return ((F64) floor((F64)x));
112 } /* end of cmFloor */
113 #endif /* SS_FLOAT */
120 * Desc: common primitive for computing the natural logrithm of x.
131 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
132 return ((F64) log((F64)x));
136 #endif /* SS_FLOAT */
143 * Desc: common primitive for computing the base 10 logrithm of x.
154 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
155 return ((F64) log10((F64)x));
157 } /* end of cmLog10 */
158 #endif /* SS_FLOAT */
164 * Desc: common primitive for computing the base 2 logrithm of x.
173 float cmLog2(uint32_t x)
175 return ((float) log2(x));
178 /**********************************************************************
180 **********************************************************************/