Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/concrt140/concrt140.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr110/tests/msvcr110.c | 42 +++++++++++++++++++++++++++++ dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr120_app/msvcr120_app.spec | 2 +- dlls/msvcrt/scheduler.c | 14 ++++++++++ 6 files changed, 60 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@details@Concurrency@@YAXHPEB_WZZ @ stub -arch=i386 ?_Confirm_cancel@_Cancellation_beacon@details@Concurrency@@QAE_NXZ @ stub -arch=win64 ?_Confirm_cancel@_Cancellation_beacon@details@Concurrency@@QEAA_NXZ -@ stub ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ +@ cdecl ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ() msvcr120.?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ @ stub ?_Current_node@location@Concurrency@@SA?AV12@XZ @ stub -arch=i386 ?_Destroy@_AsyncTaskCollection@details@Concurrency@@EAEXXZ @ stub -arch=win64 ?_Destroy@_AsyncTaskCollection@details@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@exception@std@@AAAXPBD@Z @ stub -arch=i386 ?_Copy_str@exception@std@@AAEXPBD@Z @ stub -arch=win64 ?_Copy_str@exception@std@@AEAAXPEBD@Z -@ stub ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ +@ cdecl ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ(ptr) _Context__CurrentContext @ stub ?_Current_node@location@Concurrency@@SA?AV12@XZ @ stub -arch=arm ?_DeregisterCallback@_CancellationTokenState@details@Concurrency@@QAAXPAV_CancellationTokenRegistration@23@@Z @ stub -arch=i386 ?_DeregisterCallback@_CancellationTokenState@details@Concurrency@@QAEXPAV_CancellationTokenRegistration@23@@Z diff --git a/dlls/msvcr110/tests/msvcr110.c b/dlls/msvcr110/tests/msvcr110.c index 364dd26aa82..8d3b85bfbcf 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@CurrentScheduler@Concurrency@@SAIXZ"); SET(p__CurrentScheduler__Id, "?_Id@_CurrentScheduler@details@Concurrency@@SAIXZ");
+ SET(p__Context__CurrentContext, "?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ"); + + if(sizeof(void*) == 8) + { + SET(p_Context_CurrentContext, "?CurrentContext@Context@Concurrency@@SAPEAV12@XZ"); + } + else + { + SET(p_Context_CurrentContext, "?CurrentContext@Context@Concurrency@@SAPAV12@XZ"); + } + return TRUE; }
@@ -146,10 +170,28 @@ static void test___strncnt(void) } }
+static void test_CurrentContext(void) +{ + _Context _ctx, *_pctx; + Context *ctx; + + ctx = p_Context_CurrentContext(); + ok(!!ctx, "got NULL\n"); + + if (0) /* crash Windows */ + p__Context__CurrentContext(NULL); + + memset(&_ctx, 0xcc, sizeof(_ctx)); + _pctx = p__Context__CurrentContext(&_ctx); + ok(_ctx.ctx == ctx, "expected %p, got %p\n", ctx, _ctx.ctx); + ok(_pctx == &_ctx, "expected %p, got %p\n", &_ctx, _pctx); +} + 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@exception@std@@AAAXPBD@Z @ stub -arch=i386 ?_Copy_str@exception@std@@AAEXPBD@Z @ stub -arch=win64 ?_Copy_str@exception@std@@AEAAXPEBD@Z -@ stub ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ +@ cdecl ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ() _Context__CurrentContext @ stub ?_Current_node@location@Concurrency@@SA?AV12@XZ @ stub -arch=arm ?_Destroy@_AsyncTaskCollection@details@Concurrency@@EAAXXZ @ stub -arch=i386 ?_Destroy@_AsyncTaskCollection@details@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@exception@std@@AAAXPBD@Z @ stub -arch=i386 ?_Copy_str@exception@std@@AAEXPBD@Z @ stub -arch=win64 ?_Copy_str@exception@std@@AEAAXPEBD@Z -@ stub ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ +@ cdecl ?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ() msvcr120.?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ @ stub ?_Current_node@location@Concurrency@@SA?AV12@XZ @ stub -arch=arm ?_Destroy@_AsyncTaskCollection@details@Concurrency@@EAAXXZ @ stub -arch=i386 ?_Destroy@_AsyncTaskCollection@details@Concurrency@@EAEXXZ diff --git a/dlls/msvcrt/scheduler.c b/dlls/msvcrt/scheduler.c index 59e177b5aec..317d0de18c7 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@_Context@details@Concurrency@@SA?AV123@XZ */ +_Context *__cdecl _Context__CurrentContext(_Context *ctx) +{ + TRACE("(%p)\n", ctx); + ctx->context = Context_CurrentContext(); + return ctx; +} +#endif + DEFINE_THISCALL_WRAPPER(ExternalContextBase_GetId, 4) unsigned int __thiscall ExternalContextBase_GetId(const ExternalContextBase *this) {