source: mainline/uspace/lib/math/arch/amd64/include/libarch/math.h@ 9adb61d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9adb61d was 9adb61d, checked in by Jiri Svoboda <jiri@…>, 10 years ago

Add single-precision variant for all functions. Allow generic implementations to call other functions while selecting the number of bits of precision, but not the implementation (generic or arch-specific).

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Copyright (c) 2014 Martin Decky
3 * Copyright (c) 2015 Jiri Svoboda
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libmathamd64
31 * @{
32 */
33/** @file
34 */
35
36#ifndef LIBMATH_amd64_MATH_H_
37#define LIBMATH_amd64_MATH_H_
38
39#include <ceil.h>
40#include <exp.h>
41#include <floor.h>
42#include <log.h>
43#include <mathtypes.h>
44#include <mod.h>
45#include <pow.h>
46#include <trunc.h>
47#include <trig.h>
48
49static inline float64_t ceil_f64(float64_t val)
50{
51 return float64_ceil(val);
52}
53
54static inline float32_t ceil_f32(float32_t val)
55{
56 return float32_ceil(val);
57}
58
59extern float64_t cos_f64(float64_t);
60
61static inline float32_t cos_f32(float32_t val)
62{
63 return (float32_t)cos_f64((float64_t)val);
64}
65
66static inline float64_t exp_f64(float64_t val)
67{
68 return float64_exp(val);
69}
70
71static inline float32_t exp_f32(float32_t val)
72{
73 return float32_exp(val);
74}
75
76static inline float64_t floor_f64(float64_t val)
77{
78 return float64_floor(val);
79}
80
81static inline float32_t floor_f32(float32_t val)
82{
83 return float32_floor(val);
84}
85
86static inline float64_t fmod_f64(float64_t dividend, float64_t divisor)
87{
88 return float64_mod(dividend, divisor);
89}
90
91static inline float64_t fmod_f32(float32_t dividend, float32_t divisor)
92{
93 return float32_mod(dividend, divisor);
94}
95
96static inline float64_t log_f64(float64_t val)
97{
98 return float64_log(val);
99}
100
101static inline float32_t log_f32(float32_t val)
102{
103 return float32_log(val);
104}
105
106static inline float64_t pow_f64(float64_t x, float64_t y)
107{
108 return float64_pow(x, y);
109}
110
111static inline float32_t pow_f32(float32_t x, float32_t y)
112{
113 return float32_pow(x, y);
114}
115
116extern float64_t sin_f64(float64_t);
117
118static inline float32_t sin_f32(float32_t val)
119{
120 return (float32_t)sin_f64((float64_t)val);
121}
122
123extern float64_t trunc_f64(float64_t);
124
125static inline float32_t trunc_f32(float32_t val)
126{
127 return (float32_t)trunc_f64((float64_t)val);
128}
129
130static inline float64_t ceil(float64_t val)
131{
132 return ceil_f64(val);
133}
134
135static inline float32_t ceilf(float32_t val)
136{
137 return ceil_f32(val);
138}
139
140static inline float64_t cos(float64_t val)
141{
142 return cos_f64(val);
143}
144
145static inline float32_t cosf(float32_t val)
146{
147 return cos_f32(val);
148}
149
150static inline float64_t exp(float64_t val)
151{
152 return exp_f64(val);
153}
154
155static inline float32_t expf(float32_t val)
156{
157 return exp_f32(val);
158}
159
160static inline float64_t floor(float64_t val)
161{
162 return floor_f64(val);
163}
164
165static inline float32_t floorf(float32_t val)
166{
167 return floor_f32(val);
168}
169
170static inline float64_t fmod(float64_t dividend, float64_t divisor)
171{
172 return fmod_f64(dividend, divisor);
173}
174
175static inline float32_t fmodf(float32_t dividend, float32_t divisor)
176{
177 return fmod_f32(dividend, divisor);
178}
179
180static inline float64_t log(float64_t val)
181{
182 return log_f64(val);
183}
184
185static inline float32_t logf(float32_t val)
186{
187 return log_f32(val);
188}
189
190static inline float64_t pow(float64_t x, float64_t y)
191{
192 return pow_f64(x, y);
193}
194
195static inline float32_t powf(float32_t x, float32_t y)
196{
197 return pow_f32(x, y);
198}
199
200static inline float64_t sin(float64_t val)
201{
202 return sin_f64(val);
203}
204
205static inline float32_t sinf(float32_t val)
206{
207 return sin_f32(val);
208}
209
210static inline float64_t trunc(float64_t val)
211{
212 return trunc_f64(val);
213}
214
215static inline float32_t truncf(float32_t val)
216{
217 return trunc_f32(val);
218}
219
220#endif
221
222/** @}
223 */
Note: See TracBrowser for help on using the repository browser.