Skip to content

Commit 01cd847

Browse files
committed
[UCRTBASE] Implement simplistic versions of some stubs
This is to allow ucrtbase_winetest to run without debug breaks. Proper implementations will follow.
1 parent f81c82f commit 01cd847

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

dll/win32/ucrtbase/stubs.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
#include <stdint.h>
33
#include <intrin.h>
4+
#include <malloc.h>
5+
#define _USE_MATH_DEFINES
6+
#include <math.h>
47

58
// atexit is needed by libsupc++
69
extern int __cdecl _crt_atexit(void (__cdecl*)(void));
@@ -9,13 +12,11 @@ int __cdecl atexit(void (__cdecl* function)(void))
912
return _crt_atexit(function);
1013
}
1114

12-
void* __cdecl malloc(size_t);
1315
void* __cdecl operator_new(size_t size)
1416
{
1517
return malloc(size);
1618
}
1719

18-
void free(void*);
1920
void _cdecl operator_delete(void *mem)
2021
{
2122
free(mem);
@@ -48,26 +49,25 @@ int __cdecl __acrt_initialize_sse2(void)
4849

4950
double fma(double x, double y, double z)
5051
{
51-
__debugbreak();
52-
return 0.;
52+
// Simplistic implementation
53+
return (x * y) + z;
5354
}
5455

5556
float fmaf(float x, float y, float z)
5657
{
57-
__debugbreak();
58-
return 0.;
58+
// Simplistic implementation
59+
return (x * y) + z;
5960
}
6061

6162
double log2(double x)
6263
{
63-
__debugbreak();
64-
return 0.;
64+
// Simplistic implementation: log2(x) = log(x) / log(2)
65+
return log(x) * M_LOG2E;
6566
}
6667

6768
float log2f(float x)
6869
{
69-
__debugbreak();
70-
return 0.;
70+
return (float)log2((double)x);
7171
}
7272

7373
long int lrint(double x)

0 commit comments

Comments
 (0)