Daniel Lehman : msvcr110: Add _Context::_CurrentContext.
Module: wine Branch: master Commit: a29f606e08d702ffe0cf6487105427b1dec02bff URL: https://source.winehq.org/git/wine.git/?a=commit;h=a29f606e08d702ffe0cf64871... Author: Daniel Lehman <dlehman25(a)gmail.com> Date: Mon Nov 2 20:12:08 2020 -0800 msvcr110: Add _Context::_CurrentContext. Signed-off-by: Daniel Lehman <dlehman25(a)gmail.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)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(a)details@Concurrency@@YAXHPEB_WZZ @ stub -arch=i386 ?_Confirm_cancel(a)_Cancellation_beacon@details(a)Concurrency@@QAE_NXZ @ stub -arch=win64 ?_Confirm_cancel(a)_Cancellation_beacon@details(a)Concurrency@@QEAA_NXZ -@ stub ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ +@ cdecl ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ() msvcr120.?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ @ stub ?_Current_node(a)location@Concurrency@@SA?AV12(a)XZ @ stub -arch=i386 ?_Destroy(a)_AsyncTaskCollection@details(a)Concurrency@@EAEXXZ @ stub -arch=win64 ?_Destroy(a)_AsyncTaskCollection@details(a)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(a)exception@std@@AAAXPBD(a)Z @ stub -arch=i386 ?_Copy_str(a)exception@std@@AAEXPBD(a)Z @ stub -arch=win64 ?_Copy_str(a)exception@std@@AEAAXPEBD(a)Z -@ stub ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ +@ cdecl ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ(ptr) _Context__CurrentContext @ stub ?_Current_node(a)location@Concurrency@@SA?AV12(a)XZ @ stub -arch=arm ?_DeregisterCallback(a)_CancellationTokenState@details(a)Concurrency@@QAAXPAV_CancellationTokenRegistration(a)23@@Z @ stub -arch=i386 ?_DeregisterCallback(a)_CancellationTokenState@details(a)Concurrency@@QAEXPAV_CancellationTokenRegistration(a)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(a)CurrentScheduler@Concurrency@@SAIXZ"); SET(p__CurrentScheduler__Id, "?_Id(a)_CurrentScheduler@details(a)Concurrency@@SAIXZ"); + SET(p__Context__CurrentContext, "?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ"); + + if(sizeof(void*) == 8) + { + SET(p_Context_CurrentContext, "?CurrentContext(a)Context@Concurrency@@SAPEAV12(a)XZ"); + } + else + { + SET(p_Context_CurrentContext, "?CurrentContext(a)Context@Concurrency@@SAPAV12(a)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(a)exception@std@@AAAXPBD(a)Z @ stub -arch=i386 ?_Copy_str(a)exception@std@@AAEXPBD(a)Z @ stub -arch=win64 ?_Copy_str(a)exception@std@@AEAAXPEBD(a)Z -@ stub ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ +@ cdecl ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ() _Context__CurrentContext @ stub ?_Current_node(a)location@Concurrency@@SA?AV12(a)XZ @ stub -arch=arm ?_Destroy(a)_AsyncTaskCollection@details(a)Concurrency@@EAAXXZ @ stub -arch=i386 ?_Destroy(a)_AsyncTaskCollection@details(a)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(a)exception@std@@AAAXPBD(a)Z @ stub -arch=i386 ?_Copy_str(a)exception@std@@AAEXPBD(a)Z @ stub -arch=win64 ?_Copy_str(a)exception@std@@AEAAXPEBD(a)Z -@ stub ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ +@ cdecl ?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ() msvcr120.?_CurrentContext(a)_Context@details(a)Concurrency@@SA?AV123(a)XZ @ stub ?_Current_node(a)location@Concurrency@@SA?AV12(a)XZ @ stub -arch=arm ?_Destroy(a)_AsyncTaskCollection@details(a)Concurrency@@EAAXXZ @ stub -arch=i386 ?_Destroy(a)_AsyncTaskCollection@details(a)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(a)_Context@details(a)Concurrency@@SA?AV123(a)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) {
participants (1)
-
Alexandre Julliard