Docs and build updates along with prachCfgTableIdx completion
[o-du/l2.git] / src / cm / cm_math.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18 \f
19
20 /********************************************************************20**
21
22      Name:     common MATH library functions
23   
24      Type:     C source file
25   
26      Desc:     Common functions that are implemented in
27                a portable manner. These functions are selected 
28                based on the operating system.
29
30      File:     cm_math.c
31
32 *********************************************************************21*/
33
34
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 */
41
42 #include "cm_math.h"
43 #include "cm_math.x"
44
45 #include <stdlib.h>
46
47 #include <math.h>
48
49
50 #ifdef SS_FLOAT
51 /*
52 *
53 *       Fun:   cmAbs
54 *
55 *       Desc:  common primitive for an absolute value of an integer
56 *
57 *       Ret:   absolute value of the operand 
58 *
59 *       Notes: None
60 *
61 *       File:  cm_math.c
62 *
63 */
64 #ifdef ANSI
65 PUBLIC U32 cmAbs
66 (
67 F64          val
68 )
69 #else
70 PUBLIC U32 cmAbs(val)
71 F64          val;
72 #endif
73 {
74 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
75    RETVALUE((U32) abs((int) val));/* G++ */
76 #endif
77 } /* end of cmAbs */
78 #endif /* SS_FLOAT */
79
80
81 #ifdef SS_FLOAT
82 /*
83 *
84 *       Fun:   cmPow
85 *
86 *       Desc:  common primitive for computing the power of x raised to y.
87 *
88 *       Ret:   value of x raised to the power of y.
89 *
90 *       Notes: None
91 *
92 *       File:  cm_math.c
93 *
94 */
95 #ifdef ANSI
96 PUBLIC F64 cmPow
97 (
98 F64          x,
99 F64          y
100 )
101 #else
102 PUBLIC F64 cmPow(x, y)
103 F64           x;
104 F64           y;
105 #endif
106 {
107 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
108    RETVALUE((F64) pow((F64)x, (F64)y));
109 #endif
110 } /* end of cmPow */
111 #endif /* SS_FLOAT */
112
113 #ifdef SS_FLOAT
114 /*
115 *
116 *       Fun:   cmFloor
117 *
118 *       Desc:  common primitive for computing the largest integral value 
119 *              not greater than x.
120 *
121 *       Ret:   floor value of x 
122 *
123 *       Notes: None
124 *
125 *       File:  cm_math.c
126 *
127 */
128 #ifdef ANSI
129 PUBLIC F64 cmFloor
130 (
131 F64          x
132 )
133 #else
134 PUBLIC F64 cmFloor(x)
135 F64           x;
136 #endif
137 {
138 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
139    RETVALUE((F64) floor((F64)x));
140 #endif
141
142 } /* end of cmFloor */
143 #endif /* SS_FLOAT */
144
145 #ifdef SS_FLOAT
146 /*
147 *
148 *       Fun:   cmLog
149 *
150 *       Desc:  common primitive for computing the natural logrithm of x.
151 *
152 *       Ret:   loge(x)
153 *
154 *       Notes: None
155 *
156 *       File:  cm_math.c
157 *
158 */
159 #ifdef ANSI
160 PUBLIC F64 cmLog
161 (
162 F64          x
163 )
164 #else
165 PUBLIC F64 cmLog(x)
166 F64           x;
167 #endif
168 {
169 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
170    RETVALUE((F64) log((F64)x));
171 #endif
172
173 } /* end of cmLog */
174 #endif /* SS_FLOAT */
175
176 #ifdef SS_FLOAT
177 /*
178 *
179 *       Fun:   cmLog10
180 *
181 *       Desc:  common primitive for computing the base 10 logrithm of x.
182 *
183 *       Ret:   log10(x)
184 *
185 *       Notes: None
186 *
187 *       File:  cm_math.c
188 *
189 */
190 #ifdef ANSI
191 PUBLIC F64 cmLog10
192 (
193 F64          x
194 )
195 #else
196 PUBLIC F64 cmLog10(x)
197 F64           x;
198 #endif
199 {
200 #if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX))
201    RETVALUE((F64) log10((F64)x));
202 #endif
203 } /* end of cmLog10 */
204 #endif /* SS_FLOAT */
205
206 /**********************************************************************
207          End of file
208 **********************************************************************/