Skip to content

Commit

Permalink
msvcr110: Create current scheduler in _CurrentScheduler::_Id.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lehman <[email protected]>
Signed-off-by: Piotr Caban <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
dlehman-work authored and julliard committed Jul 19, 2018
1 parent 5757c2c commit 05f9db7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dlls/msvcr110/tests/msvcr110.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static char* (CDECL *p_setlocale)(int category, const char* locale);

static unsigned int (CDECL *p_CurrentScheduler_GetNumberOfVirtualProcessors)(void);
static unsigned int (CDECL *p__CurrentScheduler__GetNumberOfVirtualProcessors)(void);
static unsigned int (CDECL *p_CurrentScheduler_Id)(void);
static unsigned int (CDECL *p__CurrentScheduler__Id)(void);

static BOOL init(void)
{
Expand All @@ -50,26 +52,39 @@ static BOOL init(void)
p_setlocale = (void*)GetProcAddress(module, "setlocale");
p_CurrentScheduler_GetNumberOfVirtualProcessors = (void*)GetProcAddress(module, "?GetNumberOfVirtualProcessors@CurrentScheduler@Concurrency@@SAIXZ");
p__CurrentScheduler__GetNumberOfVirtualProcessors = (void*)GetProcAddress(module, "?_GetNumberOfVirtualProcessors@_CurrentScheduler@details@Concurrency@@SAIXZ");
p_CurrentScheduler_Id = (void*)GetProcAddress(module, "?Id@CurrentScheduler@Concurrency@@SAIXZ");
p__CurrentScheduler__Id = (void*)GetProcAddress(module, "?_Id@_CurrentScheduler@details@Concurrency@@SAIXZ");

return TRUE;
}

static void test_CurrentScheduler(void)
{
unsigned int id;
unsigned int ncpus;
unsigned int expect;
SYSTEM_INFO si;

expect = ~0;
ncpus = p_CurrentScheduler_GetNumberOfVirtualProcessors();
ok(ncpus == expect, "expected %x, got %x\n", expect, ncpus);
id = p_CurrentScheduler_Id();
ok(id == expect, "expected %u, got %u\n", expect, id);

GetSystemInfo(&si);
expect = si.dwNumberOfProcessors;
/* these _CurrentScheduler calls trigger scheduler creation
if either is commented out, the following CurrentScheduler (no _) tests will still work */
ncpus = p__CurrentScheduler__GetNumberOfVirtualProcessors();
id = p__CurrentScheduler__Id();
ok(ncpus == expect, "expected %u, got %u\n", expect, ncpus);
ok(id == 0, "expected 0, got %u\n", id);

/* these CurrentScheduler tests assume scheduler is created */
ncpus = p_CurrentScheduler_GetNumberOfVirtualProcessors();
ok(ncpus == expect, "expected %u, got %u\n", expect, ncpus);
id = p_CurrentScheduler_Id();
ok(id == 0, "expected 0, got %u\n", id);
}

static void test_setlocale(void)
Expand Down
1 change: 1 addition & 0 deletions dlls/msvcrt/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ unsigned int __cdecl _CurrentScheduler__GetNumberOfVirtualProcessors(void)
unsigned int __cdecl _CurrentScheduler__Id(void)
{
TRACE("()\n");
get_current_scheduler();
return CurrentScheduler_Id();
}

Expand Down

0 comments on commit 05f9db7

Please sign in to comment.