reactos/dll/win32/ucrtbase/stubs.c

84 lines
1.4 KiB
C
Raw Permalink Normal View History

2024-05-27 15:40:22 +00:00
#include <stdint.h>
#include <intrin.h>
#include <malloc.h>
#define _USE_MATH_DEFINES
#include <math.h>
2024-05-27 15:40:22 +00:00
// atexit is needed by libsupc++
extern int __cdecl _crt_atexit(void (__cdecl*)(void));
int __cdecl atexit(void (__cdecl* function)(void))
{
return _crt_atexit(function);
}
void* __cdecl operator_new(size_t size)
{
return malloc(size);
}
void _cdecl operator_delete(void *mem)
{
free(mem);
}
#ifdef _M_IX86
void _chkesp_failed(void)
{
__debugbreak();
}
#endif
int __cdecl __acrt_initialize_sse2(void)
{
return 0;
}
// The following stubs cannot be implemented as stubs by spec2def, because they are intrinsics
#ifdef _MSC_VER
#pragma warning(disable:4163) // not available as an intrinsic function
#pragma warning(disable:4164) // intrinsic function not declared
#pragma function(fma)
#pragma function(fmaf)
#pragma function(log2)
#pragma function(log2f)
#pragma function(lrint)
#pragma function(lrintf)
#endif
double fma(double x, double y, double z)
{
// Simplistic implementation
return (x * y) + z;
2024-05-27 15:40:22 +00:00
}
float fmaf(float x, float y, float z)
{
// Simplistic implementation
return (x * y) + z;
2024-05-27 15:40:22 +00:00
}
double log2(double x)
{
// Simplistic implementation: log2(x) = log(x) / log(2)
return log(x) * M_LOG2E;
2024-05-27 15:40:22 +00:00
}
float log2f(float x)
{
return (float)log2((double)x);
2024-05-27 15:40:22 +00:00
}
long int lrint(double x)
{
__debugbreak();
return 0;
}
long int lrintf(float x)
{
__debugbreak();
return 0;
}