Daniel Lehman : msvcr110: Add _Context::_CurrentContext.

Alexandre Julliard julliard at winehq.org
Tue Nov 3 15:55:54 CST 2020


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

Author: Daniel Lehman <dlehman25 at gmail.com>
Date:   Mon Nov  2 20:12:08 2020 -0800

msvcr110: Add _Context::_CurrentContext.

Signed-off-by: Daniel Lehman <dlehman25 at gmail.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/concrt140/concrt140.spec       |  2 +-
 dlls/msvcr110/msvcr110.spec         |  2 +-
 dlls/msvcr110/tests/msvcr110.c      | 39 +++++++++++++++++++++++++++++++++++++
 dlls/msvcr120/msvcr120.spec         |  2 +-
 dlls/msvcr120_app/msvcr120_app.spec |  2 +-
 dlls/msvcrt/scheduler.c             | 14 +++++++++++++
 6 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/dlls/concrt140/concrt140.spec b/dlls/concrt140/concrt140.spec
index 9a8ef13aaeb..ea8a3e00dc5 100644
--- a/dlls/concrt140/concrt140.spec
+++ b/dlls/concrt140/concrt140.spec
@@ -327,7 +327,7 @@
 @ stub -arch=win64 ?_ConcRT_Trace at details@Concurrency@@YAXHPEB_WZZ
 @ stub -arch=i386 ?_Confirm_cancel at _Cancellation_beacon@details at Concurrency@@QAE_NXZ
 @ stub -arch=win64 ?_Confirm_cancel at _Cancellation_beacon@details at Concurrency@@QEAA_NXZ
-@ stub ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ
+@ cdecl ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ() msvcr120.?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ
 @ stub ?_Current_node at location@Concurrency@@SA?AV12 at XZ
 @ stub -arch=i386 ?_Destroy at _AsyncTaskCollection@details at Concurrency@@EAEXXZ
 @ stub -arch=win64 ?_Destroy at _AsyncTaskCollection@details at Concurrency@@EEAAXXZ
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 425bdfdc21a..54196f63690 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -513,7 +513,7 @@
 @ stub -arch=arm ?_Copy_str at exception@std@@AAAXPBD at Z
 @ stub -arch=i386 ?_Copy_str at exception@std@@AAEXPBD at Z
 @ stub -arch=win64 ?_Copy_str at exception@std@@AEAAXPEBD at Z
-@ stub ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ
+@ cdecl ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ(ptr) _Context__CurrentContext
 @ stub ?_Current_node at location@Concurrency@@SA?AV12 at XZ
 @ stub -arch=arm ?_DeregisterCallback at _CancellationTokenState@details at Concurrency@@QAAXPAV_CancellationTokenRegistration at 23@@Z
 @ stub -arch=i386 ?_DeregisterCallback at _CancellationTokenState@details at Concurrency@@QAEXPAV_CancellationTokenRegistration at 23@@Z
diff --git a/dlls/msvcr110/tests/msvcr110.c b/dlls/msvcr110/tests/msvcr110.c
index 364dd26aa82..f88e3122ac9 100644
--- a/dlls/msvcr110/tests/msvcr110.c
+++ b/dlls/msvcr110/tests/msvcr110.c
@@ -31,6 +31,16 @@
 
 #include <locale.h>
 
+typedef void (*vtable_ptr)(void);
+
+typedef struct {
+    const vtable_ptr *vtable;
+} Context;
+
+typedef struct {
+    Context *ctx;
+} _Context;
+
 static char* (CDECL *p_setlocale)(int category, const char* locale);
 static size_t (CDECL *p___strncnt)(const char *str, size_t count);
 
@@ -39,6 +49,9 @@ static unsigned int (CDECL *p__CurrentScheduler__GetNumberOfVirtualProcessors)(v
 static unsigned int (CDECL *p_CurrentScheduler_Id)(void);
 static unsigned int (CDECL *p__CurrentScheduler__Id)(void);
 
+static Context* (__cdecl *p_Context_CurrentContext)(void);
+static _Context* (__cdecl *p__Context__CurrentContext)(_Context*);
+
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(module,y)
 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
 
@@ -60,6 +73,17 @@ static BOOL init(void)
     SET(p_CurrentScheduler_Id, "?Id at CurrentScheduler@Concurrency@@SAIXZ");
     SET(p__CurrentScheduler__Id, "?_Id at _CurrentScheduler@details at Concurrency@@SAIXZ");
 
+    SET(p__Context__CurrentContext, "?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ");
+
+    if(sizeof(void*) == 8)
+    {
+        SET(p_Context_CurrentContext, "?CurrentContext at Context@Concurrency@@SAPEAV12 at XZ");
+    }
+    else
+    {
+        SET(p_Context_CurrentContext, "?CurrentContext at Context@Concurrency@@SAPAV12 at XZ");
+    }
+
     return TRUE;
 }
 
@@ -146,10 +170,25 @@ static void test___strncnt(void)
     }
 }
 
+static void test_CurrentContext(void)
+{
+    _Context _ctx, *ret;
+    Context *ctx;
+
+    ctx = p_Context_CurrentContext();
+    ok(!!ctx, "got NULL\n");
+
+    memset(&_ctx, 0xcc, sizeof(_ctx));
+    ret = p__Context__CurrentContext(&_ctx);
+    ok(_ctx.ctx == ctx, "expected %p, got %p\n", ctx, _ctx.ctx);
+    ok(ret == &_ctx, "expected %p, got %p\n", &_ctx, ret);
+}
+
 START_TEST(msvcr110)
 {
     if (!init()) return;
     test_CurrentScheduler(); /* MUST be first (at least among Concurrency tests) */
     test_setlocale();
     test___strncnt();
+    test_CurrentContext();
 }
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 368f376939d..f1e6fe210a7 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -509,7 +509,7 @@
 @ stub -arch=arm ?_Copy_str at exception@std@@AAAXPBD at Z
 @ stub -arch=i386 ?_Copy_str at exception@std@@AAEXPBD at Z
 @ stub -arch=win64 ?_Copy_str at exception@std@@AEAAXPEBD at Z
-@ stub ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ
+@ cdecl ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ() _Context__CurrentContext
 @ stub ?_Current_node at location@Concurrency@@SA?AV12 at XZ
 @ stub -arch=arm ?_Destroy at _AsyncTaskCollection@details at Concurrency@@EAAXXZ
 @ stub -arch=i386 ?_Destroy at _AsyncTaskCollection@details at Concurrency@@EAEXXZ
diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec
index 54a02bb0a90..87a55210951 100644
--- a/dlls/msvcr120_app/msvcr120_app.spec
+++ b/dlls/msvcr120_app/msvcr120_app.spec
@@ -505,7 +505,7 @@
 @ stub -arch=arm ?_Copy_str at exception@std@@AAAXPBD at Z
 @ stub -arch=i386 ?_Copy_str at exception@std@@AAEXPBD at Z
 @ stub -arch=win64 ?_Copy_str at exception@std@@AEAAXPEBD at Z
-@ stub ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ
+@ cdecl ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ() msvcr120.?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ
 @ stub ?_Current_node at location@Concurrency@@SA?AV12 at XZ
 @ stub -arch=arm ?_Destroy at _AsyncTaskCollection@details at Concurrency@@EAAXXZ
 @ stub -arch=i386 ?_Destroy at _AsyncTaskCollection@details at Concurrency@@EAEXXZ
diff --git a/dlls/msvcrt/scheduler.c b/dlls/msvcrt/scheduler.c
index 59e177b5aec..0701839a9dc 100644
--- a/dlls/msvcrt/scheduler.c
+++ b/dlls/msvcrt/scheduler.c
@@ -68,6 +68,10 @@ typedef struct {
 #define call_Context_dtor(this, flags) CALL_VTBL_FUNC(this, 20, \
         Context*, (Context*, unsigned int), (this, flags))
 
+typedef struct {
+    Context *context;
+} _Context;
+
 union allocator_cache_entry {
     struct _free {
         int depth;
@@ -278,6 +282,16 @@ unsigned int __cdecl Context_VirtualProcessorId(void)
     return ctx ? call_Context_GetVirtualProcessorId(ctx) : -1;
 }
 
+#if _MSVCR_VER > 100
+/* ?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ */
+_Context *__cdecl _Context__CurrentContext(_Context *ret)
+{
+    TRACE("(%p)\n", ret);
+    ret->context = Context_CurrentContext();
+    return ret;
+}
+#endif
+
 DEFINE_THISCALL_WRAPPER(ExternalContextBase_GetId, 4)
 unsigned int __thiscall ExternalContextBase_GetId(const ExternalContextBase *this)
 {




More information about the wine-cvs mailing list