Piotr Caban : msvcrt: Skip small-block heap tests if _set_sbh_threshold is not available.

Alexandre Julliard julliard at winehq.org
Fri Nov 19 15:45:32 CST 2021


Module: wine
Branch: master
Commit: acc7907dc973ce0e2fe615a0726bafdd13eb4754
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=acc7907dc973ce0e2fe615a0726bafdd13eb4754

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Nov 19 13:46:12 2021 +0100

msvcrt: Skip small-block heap tests if _set_sbh_threshold is not available.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49181
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/tests/heap.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/dlls/msvcrt/tests/heap.c b/dlls/msvcrt/tests/heap.c
index 6745aeea768..a747482130d 100644
--- a/dlls/msvcrt/tests/heap.c
+++ b/dlls/msvcrt/tests/heap.c
@@ -23,11 +23,13 @@
 #include <errno.h>
 #include "wine/test.h"
 
-static void (__cdecl *p_aligned_free)(void*) = NULL;
-static void * (__cdecl *p_aligned_malloc)(size_t,size_t) = NULL;
-static void * (__cdecl *p_aligned_offset_malloc)(size_t,size_t,size_t) = NULL;
-static void * (__cdecl *p_aligned_realloc)(void*,size_t,size_t) = NULL;
-static void * (__cdecl *p_aligned_offset_realloc)(void*,size_t,size_t,size_t) = NULL;
+static void (__cdecl *p_aligned_free)(void*);
+static void * (__cdecl *p_aligned_malloc)(size_t,size_t);
+static void * (__cdecl *p_aligned_offset_malloc)(size_t,size_t,size_t);
+static void * (__cdecl *p_aligned_realloc)(void*,size_t,size_t);
+static void * (__cdecl *p_aligned_offset_realloc)(void*,size_t,size_t,size_t);
+static int (__cdecl *p__set_sbh_threshold)(size_t);
+static size_t (__cdecl *p__get_sbh_threshold)(void);
 
 static void test_aligned_malloc(unsigned int size, unsigned int alignment)
 {
@@ -415,28 +417,37 @@ static void test_aligned(void)
 
 static void test_sbheap(void)
 {
+    HMODULE msvcrt = GetModuleHandleA("msvcrt.dll");
     void *mem;
     int threshold;
 
+    p__set_sbh_threshold = (void*)GetProcAddress(msvcrt, "_set_sbh_threshold");
+    p__get_sbh_threshold = (void*)GetProcAddress(msvcrt, "_get_sbh_threshold");
+    if (!p__set_sbh_threshold || !p__get_sbh_threshold)
+    {
+        win_skip("_set_sbh_threshold not available\n");
+        return;
+    }
+
     if(sizeof(void*) == 8) {
-        ok(!_set_sbh_threshold(0), "_set_sbh_threshold succeeded\n");
-        ok(!_set_sbh_threshold(1000), "_set_sbh_threshold succeeded\n");
+        ok(!p__set_sbh_threshold(0), "_set_sbh_threshold succeeded\n");
+        ok(!p__set_sbh_threshold(1000), "_set_sbh_threshold succeeded\n");
         return;
     }
 
     mem = malloc(1);
     ok(mem != NULL, "malloc failed\n");
 
-    ok(_set_sbh_threshold(1), "_set_sbh_threshold failed\n");
-    threshold = _get_sbh_threshold();
+    ok(p__set_sbh_threshold(1), "_set_sbh_threshold failed\n");
+    threshold = p__get_sbh_threshold();
     ok(threshold == 16, "threshold = %d\n", threshold);
 
-    ok(_set_sbh_threshold(8), "_set_sbh_threshold failed\n");
-    threshold = _get_sbh_threshold();
+    ok(p__set_sbh_threshold(8), "_set_sbh_threshold failed\n");
+    threshold = p__get_sbh_threshold();
     ok(threshold == 16, "threshold = %d\n", threshold);
 
-    ok(_set_sbh_threshold(1000), "_set_sbh_threshold failed\n");
-    threshold = _get_sbh_threshold();
+    ok(p__set_sbh_threshold(1000), "_set_sbh_threshold failed\n");
+    threshold = p__get_sbh_threshold();
     ok(threshold == 1008, "threshold = %d\n", threshold);
 
     free(mem);
@@ -449,8 +460,8 @@ static void test_sbheap(void)
     ok(mem != NULL, "realloc failed\n");
     ok(!((UINT_PTR)mem & 0xf), "incorrect alignment (%p)\n", mem);
 
-    ok(_set_sbh_threshold(0), "_set_sbh_threshold failed\n");
-    threshold = _get_sbh_threshold();
+    ok(p__set_sbh_threshold(0), "_set_sbh_threshold failed\n");
+    threshold = p__get_sbh_threshold();
     ok(threshold == 0, "threshold = %d\n", threshold);
 
     free(mem);




More information about the wine-cvs mailing list