Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
32fdffac
Commit
32fdffac
authored
Jun 26, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include: Implement some inline functions in C instead of assembly.
This way the same code can be used on all platforms. Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ff352c6d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
210 deletions
+49
-210
kernel32.spec
dlls/kernel32/kernel32.spec
+7
-7
process.c
dlls/kernel32/process.c
+1
-2
thread.c
dlls/kernel32/thread.c
+6
-116
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+0
-5
winbase.h
include/winbase.h
+35
-80
No files found.
dlls/kernel32/kernel32.spec
View file @
32fdffac
...
...
@@ -629,12 +629,12 @@
@ stdcall GetCurrentPackageFamilyName(ptr ptr)
@ stdcall GetCurrentPackageFullName(ptr ptr)
@ stdcall GetCurrentPackageId(ptr ptr)
@ stdcall -norelay GetCurrentProcess()
@ stdcall -norelay GetCurrentProcessId()
@ stdcall -norelay GetCurrentProcess()
KERNEL32_GetCurrentProcess
@ stdcall -norelay GetCurrentProcessId()
KERNEL32_GetCurrentProcessId
@ stdcall GetCurrentProcessorNumber() ntdll.NtGetCurrentProcessorNumber
@ stdcall GetCurrentProcessorNumberEx(ptr) ntdll.RtlGetCurrentProcessorNumberEx
@ stdcall -norelay GetCurrentThread()
@ stdcall -norelay GetCurrentThreadId()
@ stdcall -norelay GetCurrentThread()
KERNEL32_GetCurrentThread
@ stdcall -norelay GetCurrentThreadId()
KERNEL32_GetCurrentThreadId
@ stdcall GetCurrentThreadStackLimits(ptr ptr)
@ stdcall -arch=x86_64 GetCurrentUmsThread()
@ stdcall GetDateFormatA(long long ptr str ptr long)
...
...
@@ -700,7 +700,7 @@
@ stub -i386 GetLSCallbackTemplate
@ stdcall GetLargePageMinimum()
@ stdcall GetLargestConsoleWindowSize(long)
@ stdcall GetLastError()
@ stdcall GetLastError()
KERNEL32_GetLastError
@ stub GetLinguistLangSize
@ stdcall GetLocalTime(ptr)
@ stdcall GetLocaleInfoA(long long ptr long)
...
...
@@ -780,7 +780,7 @@
@ stdcall GetProcessFlags(long)
# @ stub GetProcessGroupAffinity
@ stdcall GetProcessHandleCount(long ptr)
@ stdcall -norelay GetProcessHeap()
@ stdcall -norelay GetProcessHeap()
KERNEL32_GetProcessHeap
@ stdcall GetProcessHeaps(long ptr)
@ stdcall GetProcessId(long)
@ stdcall GetProcessIdOfThread(long)
...
...
@@ -1414,7 +1414,7 @@
@ stdcall SetHandleInformation(long long long)
@ stdcall SetInformationJobObject(long long ptr long)
@ stub SetLastConsoleEventActive
@ stdcall SetLastError(long)
@ stdcall SetLastError(long)
KERNEL32_SetLastError
# @ stub SetLocalPrimaryComputerNameA
# @ stub SetLocalPrimaryComputerNameW
@ stdcall SetLocalTime(ptr)
...
...
dlls/kernel32/process.c
View file @
32fdffac
...
...
@@ -4258,8 +4258,7 @@ BOOL WINAPI IsWow64Process(HANDLE hProcess, PBOOL Wow64Process)
* RETURNS
* A handle representing the current process.
*/
#undef GetCurrentProcess
HANDLE
WINAPI
GetCurrentProcess
(
void
)
HANDLE
WINAPI
KERNEL32_GetCurrentProcess
(
void
)
{
return
(
HANDLE
)
~
(
ULONG_PTR
)
0
;
}
...
...
dlls/kernel32/thread.c
View file @
32fdffac
...
...
@@ -696,8 +696,7 @@ DWORD WINAPI GetProcessIdOfThread(HANDLE Thread)
* RETURNS
* Pseudohandle for the current thread
*/
#undef GetCurrentThread
HANDLE
WINAPI
GetCurrentThread
(
void
)
HANDLE
WINAPI
KERNEL32_GetCurrentThread
(
void
)
{
return
(
HANDLE
)
~
(
ULONG_PTR
)
1
;
}
...
...
@@ -711,113 +710,6 @@ void WINAPI GetCurrentThreadStackLimits(ULONG_PTR *low, ULONG_PTR *high)
*
high
=
(
ULONG_PTR
)
NtCurrentTeb
()
->
Tib
.
StackBase
;
}
#ifdef __i386__
/***********************************************************************
* SetLastError (KERNEL32.@)
*/
/* void WINAPI SetLastError( DWORD error ); */
__ASM_STDCALL_FUNC
(
SetLastError
,
4
,
"movl 4(%esp),%eax
\n\t
"
".byte 0x64
\n\t
"
"movl %eax,0x34
\n\t
"
"ret $4"
)
/***********************************************************************
* GetLastError (KERNEL32.@)
*/
/* DWORD WINAPI GetLastError(void); */
__ASM_STDCALL_FUNC
(
GetLastError
,
0
,
".byte 0x64
\n\t
movl 0x34,%eax
\n\t
ret"
)
/***********************************************************************
* GetCurrentProcessId (KERNEL32.@)
*/
/* DWORD WINAPI GetCurrentProcessId(void) */
__ASM_STDCALL_FUNC
(
GetCurrentProcessId
,
0
,
".byte 0x64
\n\t
movl 0x20,%eax
\n\t
ret"
)
/***********************************************************************
* GetCurrentThreadId (KERNEL32.@)
*/
/* DWORD WINAPI GetCurrentThreadId(void) */
__ASM_STDCALL_FUNC
(
GetCurrentThreadId
,
0
,
".byte 0x64
\n\t
movl 0x24,%eax
\n\t
ret"
)
/***********************************************************************
* GetProcessHeap (KERNEL32.@)
*/
/* HANDLE WINAPI GetProcessHeap(void) */
__ASM_STDCALL_FUNC
(
GetProcessHeap
,
0
,
".byte 0x64
\n\t
movl 0x30,%eax
\n\t
movl 0x18(%eax),%eax
\n\t
ret"
);
#elif defined(__x86_64__)
#ifdef __APPLE__
/***********************************************************************
* SetLastError (KERNEL32.@)
*/
/* void WINAPI SetLastError( DWORD error ); */
__ASM_STDCALL_FUNC
(
SetLastError
,
8
,
".byte 0x65
\n\t
movq 0x30,%rax
\n\t
movl %ecx,0x68(%rax)
\n\t
ret"
);
/***********************************************************************
* GetLastError (KERNEL32.@)
*/
/* DWORD WINAPI GetLastError(void); */
__ASM_STDCALL_FUNC
(
GetLastError
,
0
,
".byte 0x65
\n\t
movq 0x30,%rax
\n\t
movl 0x68(%rax),%eax
\n\t
ret"
);
/***********************************************************************
* GetCurrentProcessId (KERNEL32.@)
*/
/* DWORD WINAPI GetCurrentProcessId(void) */
__ASM_STDCALL_FUNC
(
GetCurrentProcessId
,
0
,
".byte 0x65
\n\t
movq 0x30,%rax
\n\t
movl 0x40(%rax),%eax
\n\t
ret"
);
/***********************************************************************
* GetCurrentThreadId (KERNEL32.@)
*/
/* DWORD WINAPI GetCurrentThreadId(void) */
__ASM_STDCALL_FUNC
(
GetCurrentThreadId
,
0
,
".byte 0x65
\n\t
movq 0x30,%rax
\n\t
movl 0x48(%rax),%eax
\n\t
ret"
);
/***********************************************************************
* GetProcessHeap (KERNEL32.@)
*/
/* HANDLE WINAPI GetProcessHeap(void) */
__ASM_STDCALL_FUNC
(
GetProcessHeap
,
0
,
".byte 0x65
\n\t
movq 0x30,%rax
\n\t
movq 0x60(%rax),%rax
\n\t
movq 0x30(%rax),%rax
\n\t
ret"
);
#else
/***********************************************************************
* SetLastError (KERNEL32.@)
*/
/* void WINAPI SetLastError( DWORD error ); */
__ASM_STDCALL_FUNC
(
SetLastError
,
8
,
".byte 0x65
\n\t
movl %ecx,0x68
\n\t
ret"
);
/***********************************************************************
* GetLastError (KERNEL32.@)
*/
/* DWORD WINAPI GetLastError(void); */
__ASM_STDCALL_FUNC
(
GetLastError
,
0
,
".byte 0x65
\n\t
movl 0x68,%eax
\n\t
ret"
);
/***********************************************************************
* GetCurrentProcessId (KERNEL32.@)
*/
/* DWORD WINAPI GetCurrentProcessId(void) */
__ASM_STDCALL_FUNC
(
GetCurrentProcessId
,
0
,
".byte 0x65
\n\t
movl 0x40,%eax
\n\t
ret"
);
/***********************************************************************
* GetCurrentThreadId (KERNEL32.@)
*/
/* DWORD WINAPI GetCurrentThreadId(void) */
__ASM_STDCALL_FUNC
(
GetCurrentThreadId
,
0
,
".byte 0x65
\n\t
movl 0x48,%eax
\n\t
ret"
);
/***********************************************************************
* GetProcessHeap (KERNEL32.@)
*/
/* HANDLE WINAPI GetProcessHeap(void) */
__ASM_STDCALL_FUNC
(
GetProcessHeap
,
0
,
".byte 0x65
\n\t
movq 0x60,%rax
\n\t
movq 0x30(%rax),%rax
\n\t
ret"
);
#endif
/* __APPLE__ */
#else
/* __x86_64__ */
/**********************************************************************
* SetLastError (KERNEL32.@)
*
...
...
@@ -826,7 +718,7 @@ __ASM_STDCALL_FUNC( GetProcessHeap, 0, ".byte 0x65\n\tmovq 0x60,%rax\n\tmovq 0x3
* RETURNS
* Nothing.
*/
void
WINAPI
SetLastError
(
DWORD
error
)
/* [in] Per-thread error code */
void
WINAPI
KERNEL32_
SetLastError
(
DWORD
error
)
/* [in] Per-thread error code */
{
NtCurrentTeb
()
->
LastErrorValue
=
error
;
}
...
...
@@ -839,7 +731,7 @@ void WINAPI SetLastError( DWORD error ) /* [in] Per-thread error code */
* RETURNS
* last-error code.
*/
DWORD
WINAPI
GetLastError
(
void
)
DWORD
WINAPI
KERNEL32_
GetLastError
(
void
)
{
return
NtCurrentTeb
()
->
LastErrorValue
;
}
...
...
@@ -852,7 +744,7 @@ DWORD WINAPI GetLastError(void)
* RETURNS
* current process identifier
*/
DWORD
WINAPI
GetCurrentProcessId
(
void
)
DWORD
WINAPI
KERNEL32_
GetCurrentProcessId
(
void
)
{
return
HandleToULong
(
NtCurrentTeb
()
->
ClientId
.
UniqueProcess
);
}
...
...
@@ -865,7 +757,7 @@ DWORD WINAPI GetCurrentProcessId(void)
* RETURNS
* current thread identifier
*/
DWORD
WINAPI
GetCurrentThreadId
(
void
)
DWORD
WINAPI
KERNEL32_
GetCurrentThreadId
(
void
)
{
return
HandleToULong
(
NtCurrentTeb
()
->
ClientId
.
UniqueThread
);
}
...
...
@@ -873,13 +765,11 @@ DWORD WINAPI GetCurrentThreadId(void)
/***********************************************************************
* GetProcessHeap (KERNEL32.@)
*/
HANDLE
WINAPI
GetProcessHeap
(
void
)
HANDLE
WINAPI
KERNEL32_
GetProcessHeap
(
void
)
{
return
NtCurrentTeb
()
->
Peb
->
ProcessHeap
;
}
#endif
/* __i386__ */
/*************************************************************************
* rtlmode_to_win32mode
*/
...
...
dlls/ntdll/ntdll_misc.h
View file @
32fdffac
...
...
@@ -122,11 +122,6 @@ extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
extern
void
(
WINAPI
*
kernel32_start_process
)(
LPTHREAD_START_ROUTINE
,
void
*
)
DECLSPEC_HIDDEN
;
/* redefine these to make sure we don't reference kernel symbols */
#define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap)
#define GetCurrentProcessId() (HandleToULong(NtCurrentTeb()->ClientId.UniqueProcess))
#define GetCurrentThreadId() (HandleToULong(NtCurrentTeb()->ClientId.UniqueThread))
/* Device IO */
extern
NTSTATUS
CDROM_DeviceIoControl
(
HANDLE
hDevice
,
HANDLE
hEvent
,
PIO_APC_ROUTINE
UserApcRoutine
,
...
...
include/winbase.h
View file @
32fdffac
...
...
@@ -2106,10 +2106,8 @@ WINBASEAPI UINT WINAPI GetCurrentDirectoryW(UINT,LPWSTR);
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
PUMS_CONTEXT
WINAPI
GetCurrentUmsThread
(
void
);
WINBASEAPI
BOOL
WINAPI
GetDefaultCommConfigA
(
LPCSTR
,
LPCOMMCONFIG
,
LPDWORD
);
...
...
@@ -3076,112 +3074,69 @@ static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
#endif
/* __i386__ */
/* A few optimizations for gcc */
#if defined(__GNUC__) && !defined(__MINGW32__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
#ifdef __WINESRC__
static
FORCEINLINE
DWORD
WINAPI
GetLastError
(
void
)
static
FORCEINLINE
HANDLE
WINAPI
GetCurrentProcess
(
void
)
{
DWORD
ret
;
#ifdef __x86_64__
#ifdef __APPLE__
DWORD
*
teb
;
__asm__
__volatile__
(
".byte 0x65
\n\t
movq 0x30,%0"
:
"=r"
(
teb
)
);
ret
=
teb
[
0x68
/
sizeof
(
DWORD
)];
#else
__asm__
__volatile__
(
".byte 0x65
\n\t
movl 0x68,%0"
:
"=r"
(
ret
)
);
#endif
#else
__asm__
__volatile__
(
".byte 0x64
\n\t
movl 0x34,%0"
:
"=r"
(
ret
)
);
#endif
return
ret
;
return
(
HANDLE
)
~
(
ULONG_PTR
)
0
;
}
static
FORCEINLINE
DWORD
WINAPI
GetCurrentProcessId
(
void
)
{
DWORD
ret
;
#ifdef __x86_64__
#ifdef __APPLE__
DWORD
*
teb
;
__asm__
__volatile__
(
".byte 0x65
\n\t
movq 0x30,%0"
:
"=r"
(
teb
)
);
ret
=
teb
[
0x40
/
sizeof
(
DWORD
)];
#else
__asm__
__volatile__
(
".byte 0x65
\n\t
movl 0x40,%0"
:
"=r"
(
ret
)
);
#endif
#else
__asm__
__volatile__
(
".byte 0x64
\n\t
movl 0x20,%0"
:
"=r"
(
ret
)
);
#endif
return
ret
;
return
HandleToULong
(
((
HANDLE
*
)
NtCurrentTeb
())[
8
]
);
}
static
FORCEINLINE
HANDLE
WINAPI
GetCurrentThread
(
void
)
{
return
(
HANDLE
)
~
(
ULONG_PTR
)
1
;
}
static
FORCEINLINE
DWORD
WINAPI
GetCurrentThreadId
(
void
)
{
DWORD
ret
;
#ifdef __x86_64__
#ifdef __APPLE__
DWORD
*
teb
;
__asm__
__volatile__
(
".byte 0x65
\n\t
movq 0x30,%0"
:
"=r"
(
teb
)
);
ret
=
teb
[
0x48
/
sizeof
(
DWORD
)];
#else
__asm__
__volatile__
(
".byte 0x65
\n\t
movl 0x48,%0"
:
"=r"
(
ret
)
);
#endif
#else
__asm__
__volatile__
(
".byte 0x64
\n\t
movl 0x24,%0"
:
"=r"
(
ret
)
);
#endif
return
ret
;
return
HandleToULong
(
((
HANDLE
*
)
NtCurrentTeb
())[
9
]
);
}
static
FORCEINLINE
void
WINAPI
SetLastError
(
DWORD
err
)
static
FORCEINLINE
DWORD
WINAPI
GetLastError
(
void
)
{
#ifdef __x86_64__
#ifdef __APPLE__
DWORD
*
teb
;
__asm__
__volatile__
(
".byte 0x65
\n\t
movq 0x30,%0"
:
"=r"
(
teb
)
);
teb
[
0x68
/
sizeof
(
DWORD
)]
=
err
;
#else
__asm__
__volatile__
(
".byte 0x65
\n\t
movl %0,0x68"
:
:
"r"
(
err
)
:
"memory"
);
#endif
#else
__asm__
__volatile__
(
".byte 0x64
\n\t
movl %0,0x34"
:
:
"r"
(
err
)
:
"memory"
);
#endif
return
*
(
DWORD
*
)((
void
**
)
NtCurrentTeb
()
+
13
);
}
static
FORCEINLINE
HANDLE
WINAPI
GetProcessHeap
(
void
)
{
HANDLE
*
pdb
;
#ifdef __x86_64__
#ifdef __APPLE__
HANDLE
**
teb
;
__asm__
__volatile__
(
".byte 0x65
\n\t
movq 0x30,%0"
:
"=r"
(
teb
)
);
pdb
=
teb
[
0x60
/
sizeof
(
HANDLE
*
)];
#else
__asm__
__volatile__
(
".byte 0x65
\n\t
movq 0x60,%0"
:
"=r"
(
pdb
)
);
#endif
return
pdb
[
0x30
/
sizeof
(
HANDLE
)];
/* get dword at offset 0x30 in pdb */
#else
__asm__
__volatile__
(
".byte 0x64
\n\t
movl 0x30,%0"
:
"=r"
(
pdb
)
);
return
pdb
[
0x18
/
sizeof
(
HANDLE
)];
/* get dword at offset 0x18 in pdb */
#endif
return
((
HANDLE
**
)
NtCurrentTeb
())[
12
][
6
];
}
static
FORCEINLINE
void
WINAPI
SetLastError
(
DWORD
err
)
{
*
(
DWORD
*
)((
void
**
)
NtCurrentTeb
()
+
13
)
=
err
;
}
#else
/* __
GNU
C__ */
#else
/* __
WINESR
C__ */
WINBASEAPI
HANDLE
WINAPI
GetCurrentProcess
(
void
);
WINBASEAPI
DWORD
WINAPI
GetCurrentProcessId
(
void
);
WINBASEAPI
HANDLE
WINAPI
GetCurrentThread
(
void
);
WINBASEAPI
DWORD
WINAPI
GetCurrentThreadId
(
void
);
WINBASEAPI
DWORD
WINAPI
GetLastError
(
void
);
WINBASEAPI
HANDLE
WINAPI
GetProcessHeap
(
void
);
WINBASEAPI
VOID
WINAPI
SetLastError
(
DWORD
);
#endif
/* __
GNU
C__ */
#endif
/* __
WINESR
C__ */
#ifdef __WINESRC__
#define GetCurrentProcess() ((HANDLE)~(ULONG_PTR)0)
#define GetCurrentThread() ((HANDLE)~(ULONG_PTR)1)
#endif
static
FORCEINLINE
HANDLE
WINAPI
GetCurrentProcessToken
(
void
)
{
return
(
HANDLE
)
~
(
ULONG_PTR
)
3
;
}
static
FORCEINLINE
HANDLE
WINAPI
GetCurrentThreadToken
(
void
)
{
return
(
HANDLE
)
~
(
ULONG_PTR
)
4
;
}
#define GetCurrentProcessToken() ((HANDLE)~(ULONG_PTR)3)
#define GetCurrentThreadToken() ((HANDLE)~(ULONG_PTR)4)
#define GetCurrentThreadEffectiveToken() ((HANDLE)~(ULONG_PTR)5)
static
FORCEINLINE
HANDLE
WINAPI
GetCurrentThreadEffectiveToken
(
void
)
{
return
(
HANDLE
)
~
(
ULONG_PTR
)
5
;
}
/* WinMain(entry point) must be declared in winbase.h. */
/* If this is not declared, we cannot compile many sources written with C++. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment