ReactOS 0.4.16-dev-340-g0540c21
pow_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// these codes and the ones in the related .asm files have to match
36#define POW_X_ONE_Y_SNAN 1
37#define POW_X_ZERO_Z_INF 2
38#define POW_X_NAN 3
39#define POW_Y_NAN 4
40#define POW_X_NAN_Y_NAN 5
41#define POW_X_NEG_Y_NOTINT 6
42#define POW_Z_ZERO 7
43#define POW_Z_DENORMAL 8
44#define POW_Z_INF 9
45
46float _powf_special(float x, float y, float z, U32 code)
47{
48 switch(code)
49 {
51 {
52 UT64 zm; zm.u64 = 0; zm.f32[0] = z;
53 _handle_errorf("powf", _FpCodePow, zm.u64, 0, AMD_F_INVALID, 0, x, y, 2);
54 }
55 break;
56
58 {
59 UT64 zm; zm.u64 = 0; zm.f32[0] = z;
61 }
62 break;
63
64 case POW_X_NAN:
65 case POW_Y_NAN:
66 case POW_X_NAN_Y_NAN:
68 {
69 UT64 zm; zm.u64 = 0; zm.f32[0] = z;
71 }
72 break;
73
74 case POW_Z_ZERO:
75 {
76 UT64 zm; zm.u64 = 0; zm.f32[0] = z;
78 }
79 break;
80
81 case POW_Z_INF:
82 {
83 UT64 zm; zm.u64 = 0; zm.f32[0] = z;
85 }
86 break;
87 }
88
89 return z;
90}
91
92double _pow_special(double x, double y, double z, U32 code)
93{
94 switch(code)
95 {
97 {
98 UT64 zm; zm.f64 = z;
100 }
101 break;
102
103 case POW_X_NAN:
104 case POW_Y_NAN:
105 case POW_X_NAN_Y_NAN:
107 {
108 UT64 zm; zm.f64 = z;
110 }
111 break;
112
113 case POW_Z_ZERO:
114 case POW_Z_DENORMAL:
115 {
116 UT64 zm; zm.f64 = z;
118 }
119 break;
120
121 case POW_Z_INF:
122 {
123 UT64 zm; zm.f64 = z;
125 }
126 break;
127 }
128
129 return z;
130}
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
@ _FpCodePow
Definition: fpieee.h:58
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
#define _DOMAIN
Definition: math.h:39
#define _SING
Definition: math.h:40
#define _UNDERFLOW
Definition: math.h:42
#define _OVERFLOW
Definition: math.h:41
#define AMD_F_DIVBYZERO
Definition: libm_new.h:85
#define AMD_F_INEXACT
Definition: libm_new.h:82
#define AMD_F_UNDERFLOW
Definition: libm_new.h:84
#define AMD_F_INVALID
Definition: libm_new.h:86
#define AMD_F_OVERFLOW
Definition: libm_new.h:83
#define POW_Z_INF
Definition: pow_special.c:44
#define POW_X_NAN
Definition: pow_special.c:38
#define POW_X_NEG_Y_NOTINT
Definition: pow_special.c:41
#define POW_X_NAN_Y_NAN
Definition: pow_special.c:40
#define POW_X_ZERO_Z_INF
Definition: pow_special.c:37
float _powf_special(float x, float y, float z, U32 code)
Definition: pow_special.c:46
double _pow_special(double x, double y, double z, U32 code)
Definition: pow_special.c:92
#define POW_Z_DENORMAL
Definition: pow_special.c:43
#define POW_Y_NAN
Definition: pow_special.c:39
#define POW_X_ONE_Y_SNAN
Definition: pow_special.c:36
#define POW_Z_ZERO
Definition: pow_special.c:42
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