ReactOS 0.4.17-dev-1421-g4623072
stubs.c
Go to the documentation of this file.
1
2#include <stdint.h>
3#include <intrin.h>
4#include <malloc.h>
5#define _USE_MATH_DEFINES
6#include <math.h>
7
8// atexit is needed by libsupc++
9extern int __cdecl _crt_atexit(void (__cdecl*)(void));
10int __cdecl atexit(void (__cdecl* function)(void))
11{
12 return _crt_atexit(function);
13}
14
16{
17 return malloc(size);
18}
19
20void _cdecl operator_delete(void *mem)
21{
22 free(mem);
23}
24
25#ifdef _M_IX86
26void _chkesp_failed(void)
27{
29}
30#endif
31
33{
34 return 0;
35}
36
37// The following stubs cannot be implemented as stubs by spec2def, because they are intrinsics
38
39#ifdef _MSC_VER
40#pragma warning(disable:4163) // not available as an intrinsic function
41#pragma warning(disable:4164) // intrinsic function not declared
42#pragma function(fma)
43#pragma function(fmaf)
44#pragma function(log2)
45#pragma function(log2f)
46#pragma function(lrint)
47#pragma function(lrintf)
48#pragma function(copysign)
49#pragma function(copysignf)
50#pragma function(fmax)
51#pragma function(fmaxf)
52#pragma function(fmin)
53#pragma function(fminf)
54#endif
55
56double copysign(double x, double y)
57{
58 return _copysign(x, y);
59}
60
61float copysignf(float x, float y)
62{
63 return (float)_copysign((double)x, (double)y);
64}
65
66double fmax(double x, double y)
67{
68 if (x != x) return y;
69 if (y != y) return x;
70 return (x < y) ? y : x;
71}
72
73float fmaxf(float x, float y)
74{
75 return (float)fmax((double)x, (double)y);
76}
77
78double fmin(double x, double y)
79{
80 if (x != x) return y;
81 if (y != y) return x;
82 return (x < y) ? x : y;
83}
84
85float fminf(float x, float y)
86{
87 return (float)fmin((double)x, (double)y);
88}
89
90double fma(double x, double y, double z)
91{
92 // Simplistic implementation
93 return (x * y) + z;
94}
95
96float fmaf(float x, float y, float z)
97{
98 // Simplistic implementation
99 return (x * y) + z;
100}
101
102double log2(double x)
103{
104 // Simplistic implementation: log2(x) = log(x) / log(2)
105 return log(x) * M_LOG2E;
106}
107
108float log2f(float x)
109{
110 return (float)log2((double)x);
111}
112
113long int lrint(double x)
114{
115 __debugbreak();
116 return 0;
117}
118
119long int lrintf(float x)
120{
121 __debugbreak();
122 return 0;
123}
void _chkesp_failed(void)
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define __cdecl
Definition: corecrt.h:121
_ACRTIMP double __cdecl _copysign(double, double)
Definition: copysign.c:17
#define copysignf(x, y)
Definition: math.h:254
#define M_LOG2E
Definition: math.h:405
#define copysign(x, y)
Definition: math.h:253
long int lrintf(float x)
Definition: stubs.c:119
long int lrint(double x)
Definition: stubs.c:113
double fmax(double x, double y)
Definition: stubs.c:66
double log2(double x)
Definition: stubs.c:102
int __cdecl _crt_atexit(void(__cdecl *)(void))
Definition: onexit.cpp:41
float log2f(float x)
Definition: stubs.c:108
float fmaxf(float x, float y)
Definition: stubs.c:73
int __cdecl __acrt_initialize_sse2(void)
Definition: stubs.c:32
float fminf(float x, float y)
Definition: stubs.c:85
int __cdecl atexit(void(__cdecl *function)(void))
Definition: stubs.c:10
float fmaf(float x, float y, float z)
Definition: stubs.c:96
void *__cdecl operator_new(size_t size)
Definition: stubs.c:15
double fma(double x, double y, double z)
Definition: stubs.c:90
double fmin(double x, double y)
Definition: stubs.c:78
void _cdecl operator_delete(void *mem)
Definition: stubs.c:20
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
GLdouble GLdouble z
Definition: glext.h:5874
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
#define log(outFile, fmt,...)
Definition: util.h:15
Definition: mem.c:349