From 02b74d3fd372ef6bb94d74590341a0b5b3f3dee8 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Thu, 17 May 2012 19:28:31 +0200 Subject: [PATCH] ntdll: Implement NtGetCurrentProcessorNumber. --- dlls/kernel32/kernel32.spec | 1 + dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/thread.c | 17 +++++++++++++++++ include/winbase.h | 2 ++ include/winnt.h | 7 +++++++ 5 files changed, 28 insertions(+) diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 9b786a93698..e5a70cf9d21 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -498,6 +498,7 @@ @ stdcall GetCurrentDirectoryW(long ptr) @ stdcall GetCurrentProcess() @ stdcall GetCurrentProcessId() +@ stdcall GetCurrentProcessorNumber() ntdll.NtGetCurrentProcessorNumber @ stdcall GetCurrentThread() @ stdcall GetCurrentThreadId() @ stdcall GetDateFormatA(long long ptr str ptr long) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index bd9d41eb561..cff708158c3 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -176,6 +176,7 @@ @ stdcall NtFreeVirtualMemory(long ptr ptr long) @ stdcall NtFsControlFile(long long long long long long long long long long) @ stdcall NtGetContextThread(long ptr) +@ stdcall NtGetCurrentProcessorNumber() # @ stub NtGetDevicePowerState @ stub NtGetPlugPlayEvent @ stdcall NtGetTickCount() diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index e328c5f590a..a0d414a0313 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -1173,3 +1173,20 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, return STATUS_NOT_IMPLEMENTED; } } + +/****************************************************************************** + * NtGetCurrentProcessorNumber (NTDLL.@) + * + * Return the processor, on which the thread is running + * + */ +ULONG WINAPI NtGetCurrentProcessorNumber(void) +{ + + if (NtCurrentTeb()->Peb->NumberOfProcessors > 1) { + FIXME("need multicore support (%d processors)\n", NtCurrentTeb()->Peb->NumberOfProcessors); + } + + /* fallback to the first processor */ + return 0; +} diff --git a/include/winbase.h b/include/winbase.h index 2cb3d1ac6ce..8b5805cd3ee 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -1634,6 +1634,8 @@ WINADVAPI BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA); WINADVAPI BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW); #define GetCurrentHwProfile WINELIB_NAME_AW(GetCurrentHwProfile) WINBASEAPI HANDLE WINAPI GetCurrentProcess(void); +WINBASEAPI DWORD WINAPI GetCurrentProcessorNumber(void); +WINBASEAPI VOID WINAPI GetCurrentProcessorNumberEx(PPROCESSOR_NUMBER); WINBASEAPI HANDLE WINAPI GetCurrentThread(void); #define GetCurrentTime() GetTickCount() WINBASEAPI BOOL WINAPI GetDefaultCommConfigA(LPCSTR,LPCOMMCONFIG,LPDWORD); diff --git a/include/winnt.h b/include/winnt.h index 9bde031c1b3..02c92e62941 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -5286,6 +5286,13 @@ typedef struct _GROUP_AFFINITY WORD Reserved[3]; } GROUP_AFFINITY, *PGROUP_AFFINITY; +typedef struct _PROCESSOR_NUMBER +{ + WORD Group; + BYTE Number; + BYTE Reserved; +} PROCESSOR_NUMBER, *PPROCESSOR_NUMBER; + typedef struct _PROCESSOR_RELATIONSHIP { BYTE Flags;