ReactOS 0.4.16-dev-250-g3ecd236
exp_special.c
Go to the documentation of this file.
1
2/*******************************************************************************
3MIT License
4-----------
5
6Copyright (c) 2002-2019 Advanced Micro Devices, Inc.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this Software and associated documentaon files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25*******************************************************************************/
26
27#include <fpieee.h>
28#include <excpt.h>
29#include <float.h>
30#include <math.h>
31#include <errno.h>
32
33#include "libm_new.h"
34
35// y = expf(x)
36// y = exp(x)
37
38// these codes and the ones in the related .asm files have to match
39#define EXP_X_NAN 1
40#define EXP_Y_ZERO 2
41#define EXP_Y_INF 3
42
43float _expf_special(float x, float y, U32 code)
44{
45 switch(code)
46 {
47 case EXP_X_NAN:
48 {
49 UT64 ym; ym.u64 = 0; ym.f32[0] = y;
50 _handle_errorf("expf", _FpCodeExp, ym.u64, _DOMAIN, 0, EDOM, x, 0.0, 1);
51 }
52 break;
53
54 case EXP_Y_ZERO:
55 {
56 UT64 ym; ym.u64 = 0; ym.f32[0] = y;
58 }
59 break;
60
61 case EXP_Y_INF:
62 {
63 UT64 ym; ym.u64 = 0; ym.f32[0] = y;
65
66 }
67 break;
68 }
69
70 return y;
71}
72
73double _exp_special(double x, double y, U32 code)
74{
75 switch(code)
76 {
77 case EXP_X_NAN:
78 {
79 UT64 ym; ym.f64 = y;
80 _handle_error("exp", _FpCodeExp, ym.u64, _DOMAIN, 0, EDOM, x, 0.0, 1);
81 }
82 break;
83
84 case EXP_Y_ZERO:
85 {
86 UT64 ym; ym.f64 = y;
88 }
89 break;
90
91 case EXP_Y_INF:
92 {
93 UT64 ym; ym.f64 = y;
95 }
96 break;
97 }
98
99
100 return y;
101}
double __cdecl _handle_error(char *fname, int opcode, unsigned long long value, int type, int flags, int error, double arg1, double arg2, int nargs)
Handles an error condition.
Definition: _handle_error.c:34
float __cdecl _handle_errorf(char *fname, int opcode, unsigned long long value, int type, int flags, int error, float arg1, float arg2, int nargs)
Definition: _handle_error.c:56
#define ERANGE
Definition: acclib.h:92
#define EDOM
Definition: errno.h:39
double _exp_special(double x, double y, U32 code)
Definition: exp_special.c:73
float _expf_special(float x, float y, U32 code)
Definition: exp_special.c:43
#define EXP_Y_ZERO
Definition: exp_special.c:40
#define EXP_X_NAN
Definition: exp_special.c:39
#define EXP_Y_INF
Definition: exp_special.c:41
@ _FpCodeExp
Definition: fpieee.h:49
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define _DOMAIN
Definition: math.h:39
#define _UNDERFLOW
Definition: math.h:42
#define _OVERFLOW
Definition: math.h:41
#define AMD_F_INEXACT
Definition: libm_new.h:82
#define AMD_F_UNDERFLOW
Definition: libm_new.h:84
#define AMD_F_OVERFLOW
Definition: libm_new.h:83
Definition: inflate.c:139
Definition: libm_new.h:47
F64 f64
Definition: libm_new.h:48
U64 u64
Definition: libm_new.h:49
F32 f32[2]
Definition: libm_new.h:51
unsigned int U32
Definition: xxhash.c:195