Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
0d0fd755
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0d0fd755
编写于
6月 17, 2022
作者:
A
Aaron Robinson
提交者:
GitHub
6月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove #define Sleep (#70868)
* Remove #define Sleep
上级
051b4828
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
13 addition
and
95 deletion
+13
-95
src/coreclr/gc/env/gcenv.os.h
src/coreclr/gc/env/gcenv.os.h
+0
-11
src/coreclr/vm/comsynchronizable.cpp
src/coreclr/vm/comsynchronizable.cpp
+0
-3
src/coreclr/vm/comsynchronizable.h
src/coreclr/vm/comsynchronizable.h
+0
-2
src/coreclr/vm/ecalllist.h
src/coreclr/vm/ecalllist.h
+0
-2
src/coreclr/vm/hosting.cpp
src/coreclr/vm/hosting.cpp
+7
-44
src/coreclr/vm/threads.cpp
src/coreclr/vm/threads.cpp
+1
-7
src/coreclr/vm/threadsuspend.cpp
src/coreclr/vm/threadsuspend.cpp
+2
-4
src/coreclr/vm/win32threadpool.cpp
src/coreclr/vm/win32threadpool.cpp
+3
-22
未找到文件。
src/coreclr/gc/env/gcenv.os.h
浏览文件 @
0d0fd755
...
...
@@ -6,17 +6,6 @@
#ifndef __GCENV_OS_H__
#define __GCENV_OS_H__
#ifdef Sleep
// This is a funny workaround for the fact that "common.h" defines Sleep to be
// Dont_Use_Sleep, with the hope of causing linker errors whenever someone tries to use sleep.
//
// However, GCToOSInterface defines a function called Sleep, which (due to this define) becomes
// "Dont_Use_Sleep", which the GC in turn happily uses. The symbol that GCToOSInterface actually
// exported was called "GCToOSInterface::Dont_Use_Sleep". While we progress in making the GC standalone,
// we'll need to break the dependency on common.h (the VM header) and this problem will become moot.
#undef Sleep
#endif // Sleep
#ifdef HAS_SYSTEM_YIELDPROCESSOR
// YieldProcessor is defined to Dont_Use_YieldProcessor. Restore it to the system-default implementation for the GC.
#undef YieldProcessor
...
...
src/coreclr/vm/comsynchronizable.cpp
浏览文件 @
0d0fd755
...
...
@@ -463,7 +463,6 @@ FCIMPL2(FC_BOOL_RET, ThreadNative::Join, ThreadBaseObject* pThisUNSAFE, INT32 Ti
}
FCIMPLEND
#undef Sleep
FCIMPL1
(
void
,
ThreadNative
::
Sleep
,
INT32
iTime
)
{
FCALL_CONTRACT
;
...
...
@@ -476,8 +475,6 @@ FCIMPL1(void, ThreadNative::Sleep, INT32 iTime)
}
FCIMPLEND
#define Sleep(dwMilliseconds) Dont_Use_Sleep(dwMilliseconds)
extern
"C"
void
QCALLTYPE
ThreadNative_UninterruptibleSleep0
()
{
QCALL_CONTRACT
;
...
...
src/coreclr/vm/comsynchronizable.h
浏览文件 @
0d0fd755
...
...
@@ -64,9 +64,7 @@ public:
static
FCDECL1
(
void
,
Interrupt
,
ThreadBaseObject
*
pThisUNSAFE
);
static
FCDECL1
(
FC_BOOL_RET
,
IsAlive
,
ThreadBaseObject
*
pThisUNSAFE
);
static
FCDECL2
(
FC_BOOL_RET
,
Join
,
ThreadBaseObject
*
pThisUNSAFE
,
INT32
Timeout
);
#undef Sleep
static
FCDECL1
(
void
,
Sleep
,
INT32
iTime
);
#define Sleep(a) Dont_Use_Sleep(a)
static
FCDECL1
(
void
,
Initialize
,
ThreadBaseObject
*
pThisUNSAFE
);
static
FCDECL2
(
void
,
SetBackground
,
ThreadBaseObject
*
pThisUNSAFE
,
CLR_BOOL
isBackground
);
static
FCDECL1
(
FC_BOOL_RET
,
IsBackground
,
ThreadBaseObject
*
pThisUNSAFE
);
...
...
src/coreclr/vm/ecalllist.h
浏览文件 @
0d0fd755
...
...
@@ -369,9 +369,7 @@ FCFuncEnd()
FCFuncStart
(
gThreadFuncs
)
FCFuncElement
(
"InternalGetCurrentThread"
,
GetThread
)
#undef Sleep
FCFuncElement
(
"SleepInternal"
,
ThreadNative
::
Sleep
)
#define Sleep(a) Dont_Use_Sleep(a)
FCFuncElement
(
"Initialize"
,
ThreadNative
::
Initialize
)
FCFuncElement
(
"SpinWaitInternal"
,
ThreadNative
::
SpinWait
)
FCFuncElement
(
"GetCurrentThreadNative"
,
ThreadNative
::
GetCurrentThread
)
...
...
src/coreclr/vm/hosting.cpp
浏览文件 @
0d0fd755
...
...
@@ -8,7 +8,6 @@
#include "corhost.h"
#include "threads.h"
#undef VirtualAlloc
LPVOID
ClrVirtualAlloc
(
LPVOID
lpAddress
,
SIZE_T
dwSize
,
DWORD
flAllocationType
,
DWORD
flProtect
)
{
CONTRACTL
{
...
...
@@ -78,36 +77,18 @@ LPVOID ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType,
}
}
#define VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect) Dont_Use_VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect)
#undef VirtualFree
BOOL
ClrVirtualFree
(
LPVOID
lpAddress
,
SIZE_T
dwSize
,
DWORD
dwFreeType
)
{
CONTRACTL
{
NOTHROW
;
GC_NOTRIGGER
;
}
CONTRACTL_END
;
BOOL
ClrVirtualFree
(
LPVOID
lpAddress
,
SIZE_T
dwSize
,
DWORD
dwFreeType
)
{
WRAPPER_NO_CONTRACT
;
return
(
BOOL
)(
BYTE
)
::
VirtualFree
(
lpAddress
,
dwSize
,
dwFreeType
);
}
#define VirtualFree(lpAddress, dwSize, dwFreeType) Dont_Use_VirtualFree(lpAddress, dwSize, dwFreeType)
#undef VirtualQuery
SIZE_T
ClrVirtualQuery
(
LPCVOID
lpAddress
,
PMEMORY_BASIC_INFORMATION
lpBuffer
,
SIZE_T
dwLength
)
{
CONTRACTL
{
NOTHROW
;
GC_NOTRIGGER
;
}
CONTRACTL_END
;
{
return
::
VirtualQuery
(
lpAddress
,
lpBuffer
,
dwLength
);
}
WRAPPER_NO_CONTRACT
;
return
::
VirtualQuery
(
lpAddress
,
lpBuffer
,
dwLength
);
}
#define VirtualQuery(lpAddress, lpBuffer, dwLength) Dont_Use_VirtualQuery(lpAddress, lpBuffer, dwLength)
#if defined(_DEBUG) && !defined(TARGET_UNIX)
static
VolatilePtr
<
BYTE
>
s_pStartOfUEFSection
=
NULL
;
...
...
@@ -115,7 +96,6 @@ static VolatilePtr<BYTE> s_pEndOfUEFSectionBoundary = NULL;
static
Volatile
<
DWORD
>
s_dwProtection
=
0
;
#endif // _DEBUG && !TARGET_UNIX
#undef VirtualProtect
BOOL
ClrVirtualProtect
(
LPVOID
lpAddress
,
SIZE_T
dwSize
,
DWORD
flNewProtect
,
PDWORD
lpflOldProtect
)
{
CONTRACTL
...
...
@@ -235,29 +215,12 @@ BOOL ClrVirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWO
return
::
VirtualProtect
(
lpAddress
,
dwSize
,
flNewProtect
,
lpflOldProtect
);
}
#define VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect) Dont_Use_VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect)
#undef SleepEx
DWORD
ClrSleepEx
(
DWORD
dwMilliseconds
,
BOOL
bAlertable
)
{
CONTRACTL
{
NOTHROW
;
GC_NOTRIGGER
;
MODE_ANY
;
}
CONTRACTL_END
;
DWORD
res
;
{
res
=
::
SleepEx
(
dwMilliseconds
,
bAlertable
);
}
return
res
;
WRAPPER_NO_CONTRACT
;
return
::
SleepEx
(
dwMilliseconds
,
bAlertable
);
}
#define SleepEx(dwMilliseconds,bAlertable) \
Dont_Use_SleepEx(dwMilliseconds,bAlertable)
// non-zero return value if this function causes the OS to switch to another thread
// See file:spinlock.h#SwitchToThreadSpinning for an explanation of dwSwitchCount
...
...
src/coreclr/vm/threads.cpp
浏览文件 @
0d0fd755
...
...
@@ -1006,10 +1006,8 @@ HRESULT Thread::DetachThread(BOOL fDLLThreadDetach)
while
(
m_dwThreadHandleBeingUsed
>
0
)
{
// Another thread is using the handle now.
#undef Sleep
// We can not call __SwitchToThread since we can not go back to host.
::
Sleep
(
10
);
#define Sleep(a) Dont_Use_Sleep(a)
ClrSleepEx
(
10
,
FALSE
);
}
if
(
m_WeOwnThreadHandle
&&
m_ThreadHandleForClose
==
INVALID_HANDLE_VALUE
)
{
...
...
@@ -6748,11 +6746,7 @@ BOOL Thread::DoesRegionContainGuardPage(UINT_PTR uLowAddress, UINT_PTR uHighAddr
while
(
uStartOfCurrentRegion
<
uHighAddress
)
{
#undef VirtualQuery
// This code can run below YieldTask, which means that it must not call back into the host.
// The reason is that YieldTask is invoked by the host, and the host needs not be reentrant.
dwRes
=
VirtualQuery
((
const
void
*
)
uStartOfCurrentRegion
,
&
meminfo
,
sizeof
(
meminfo
));
#define VirtualQuery(lpAddress, lpBuffer, dwLength) Dont_Use_VirtualQuery(lpAddress, lpBuffer, dwLength)
// If the query fails then assume we have no guard page.
if
(
sizeof
(
meminfo
)
!=
dwRes
)
...
...
src/coreclr/vm/threadsuspend.cpp
浏览文件 @
0d0fd755
...
...
@@ -5198,17 +5198,15 @@ BOOL ThreadCaughtInKernelModeExceptionHandling(Thread *pThread, CONTEXT *ctx)
// still has page guard bit set. We can't hit the race in such case so we just leave. Besides, we can't access the
// memory with page guard flag or not committed.
MEMORY_BASIC_INFORMATION
mbi
;
#undef VirtualQuery
// This code can run below YieldTask, which means that it must not call back into the host.
// The reason is that YieldTask is invoked by the host, and the host needs not be reentrant.
if
(
VirtualQuery
((
LPCVOID
)(
UINT_PTR
)
ctx
->
Esp
,
&
mbi
,
sizeof
(
mbi
))
==
sizeof
(
mbi
))
{
if
(
!
(
mbi
.
State
&
MEM_COMMIT
)
||
(
mbi
.
Protect
&
PAGE_GUARD
))
return
FALSE
;
}
else
{
STRESS_LOG0
(
LF_SYNC
,
ERROR
,
"VirtualQuery failed!"
);
#define VirtualQuery(lpAddress, lpBuffer, dwLength) Dont_Use_VirtualQuery(lpAddress, lpBuffer, dwLength)
}
// The first two values on the stack should be a pointer to the EXCEPTION_RECORD and a pointer to the CONTEXT.
UINT_PTR
Esp
=
(
UINT_PTR
)
ctx
->
Esp
;
...
...
src/coreclr/vm/win32threadpool.cpp
浏览文件 @
0d0fd755
...
...
@@ -2456,15 +2456,7 @@ DWORD WINAPI ThreadpoolMgr::WaitThreadStart(LPVOID lpArgs)
if
(
threadCB
->
NumActiveWaits
==
0
)
{
#undef SleepEx
// <TODO>@TODO Consider doing a sleep for an idle period and terminating the thread if no activity</TODO>
//We use SleepEx instead of CLRSLeepEx because CLRSleepEx calls into SQL(or other hosts) in hosted
//scenarios. SQL does not deliver APC's, and the waithread wait insertion/deletion logic depends on
//APC's being delivered.
status
=
SleepEx
(
INFINITE
,
TRUE
);
#define SleepEx(a,b) Dont_Use_SleepEx(a,b)
status
=
ClrSleepEx
(
INFINITE
,
TRUE
);
_ASSERTE
(
status
==
WAIT_IO_COMPLETION
);
}
else
if
(
IsWaitThreadAPCPending
())
...
...
@@ -2474,15 +2466,7 @@ DWORD WINAPI ThreadpoolMgr::WaitThreadStart(LPVOID lpArgs)
//allow the thread to enter alertable wait and thus cause the APC to fire.
ResetWaitThreadAPCPending
();
//We use SleepEx instead of CLRSLeepEx because CLRSleepEx calls into SQL(or other hosts) in hosted
//scenarios. SQL does not deliver APC's, and the waithread wait insertion/deletion logic depends on
//APC's being delivered.
#undef SleepEx
status
=
SleepEx
(
0
,
TRUE
);
#define SleepEx(a,b) Dont_Use_SleepEx(a,b)
status
=
ClrSleepEx
(
0
,
TRUE
);
continue
;
}
else
...
...
@@ -4480,10 +4464,7 @@ void ThreadpoolMgr::TimerThreadFire()
EX_TRY
{
DWORD
timeout
=
FireTimers
();
#undef SleepEx
SleepEx
(
timeout
,
TRUE
);
#define SleepEx(a,b) Dont_Use_SleepEx(a,b)
ClrSleepEx
(
timeout
,
TRUE
);
// the thread could wake up either because an APC completed or the sleep timeout
// in both case, we need to sweep the timer queue, firing timers, and readjusting
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录