Skip to content

Commit 413b2af

Browse files
authored
Revert "Reduce CoreCLR PAL (#76832)"
This reverts commit f745eb9.
1 parent 5892ef2 commit 413b2af

File tree

83 files changed

+6819
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6819
-115
lines changed

src/coreclr/dlls/mscordac/mscordac_unixexports.src

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ nativeStringResourceTable_mscorrc
9999
#CloseHandle
100100
#DebugBreak
101101
#DeleteCriticalSection
102+
#DeleteFileW
102103
#DuplicateHandle
103104
#EnterCriticalSection
104105
#FindClose
@@ -111,6 +112,7 @@ nativeStringResourceTable_mscorrc
111112
#FreeLibrary
112113
#FileTimeToSystemTime
113114
#GetACP
115+
#GetCurrentDirectoryW
114116
#GetCurrentProcess
115117
#GetCurrentProcessId
116118
#GetCurrentThreadId
@@ -139,6 +141,7 @@ nativeStringResourceTable_mscorrc
139141
#LoadLibraryExW
140142
#MapViewOfFile
141143
#MapViewOfFileEx
144+
#MoveFileExW
142145
#MultiByteToWideChar
143146
#OpenProcess
144147
#OutputDebugStringW

src/coreclr/ilasm/main.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -846,16 +846,8 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv)
846846
*pc = W('.');
847847
}
848848
wcscpy_s(pc+1,4,W("PDB"));
849-
850-
#ifdef TARGET_WINDOWS
851-
_wremove(wzOutputFilename);
852-
#else
853-
MAKE_UTF8PTR_FROMWIDE_NOTHROW(szOutputFilename, wzOutputFilename);
854-
if (szOutputFilename != NULL)
855-
{
856-
remove(szOutputFilename);
857-
}
858-
#endif
849+
#undef DeleteFileW
850+
DeleteFileW(wzOutputFilename);
859851
}
860852
if (exitval == 0)
861853
{

src/coreclr/inc/clrconfigvalues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DisableStarvationDetection, W("Thre
529529
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DebugBreakOnWorkerStarvation, W("ThreadPool_DebugBreakOnWorkerStarvation"), 0, "Breaks into the debugger if the ThreadPool detects work queue starvation")
530530
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_EnableWorkerTracking, W("ThreadPool_EnableWorkerTracking"), 0, "Enables extra expensive tracking of how many workers threads are working simultaneously")
531531
#ifdef TARGET_ARM64
532-
// Spinning scheme is currently different on ARM64
532+
// Spinning scheme is currently different on ARM64, see CLRLifoSemaphore::Wait(DWORD, UINT32, UINT32)
533533
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 0x32, "Maximum number of spins per processor a thread pool worker thread performs before waiting for work")
534534
#else // !TARGET_ARM64
535535
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 0x46, "Maximum number of spins a thread pool worker thread performs before waiting for work")

src/coreclr/inc/holder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,14 @@ typedef Wrapper<HANDLE, DoNothing<HANDLE>, VoidFindClose, (UINT_PTR) -1> FindHan
11441144

11451145
typedef Wrapper<void *, DoNothing, VoidUnmapViewOfFile> MapViewHolder;
11461146

1147+
#ifdef WszDeleteFile
1148+
// Deletes a file with the specified path. Do not use if you care about failures
1149+
// deleting the file, as failures are ignored by VoidDeleteFile.
1150+
FORCEINLINE void VoidDeleteFile(LPCWSTR wszFilePath) { WszDeleteFile(wszFilePath); }
1151+
typedef Wrapper<LPCWSTR, DoNothing<LPCWSTR>, VoidDeleteFile, NULL> DeleteFileHolder;
1152+
#endif // WszDeleteFile
1153+
1154+
11471155
//-----------------------------------------------------------------------------
11481156
// Misc holders
11491157
//-----------------------------------------------------------------------------

src/coreclr/inc/longfilepathwrappers.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ GetFileAttributesExWrapper(
3434
_In_ GET_FILEEX_INFO_LEVELS fInfoLevelId,
3535
_Out_writes_bytes_(sizeof(WIN32_FILE_ATTRIBUTE_DATA)) LPVOID lpFileInformation
3636
);
37+
BOOL
38+
DeleteFileWrapper(
39+
_In_ LPCWSTR lpFileName
40+
);
3741

3842
#ifndef HOST_UNIX
3943
BOOL
@@ -62,6 +66,10 @@ DWORD WINAPI GetTempPathWrapper(
6266
SString& lpBuffer
6367
);
6468

69+
DWORD WINAPI GetCurrentDirectoryWrapper(
70+
SString& lpBuffer
71+
);
72+
6573
DWORD
6674
GetModuleFileNameWrapper(
6775
_In_opt_ HMODULE hModule,

src/coreclr/inc/winwrap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#undef OpenSemaphore
7272
#undef CreateWaitableTimer
7373
#undef CreateFileMapping
74+
#undef OpenFileMapping
7475
#undef LoadLibrary
7576
#undef LoadLibraryEx
7677
#undef GetModuleFileName
@@ -91,16 +92,19 @@
9192
#undef GetSystemDirectory
9293
#undef GetTempPath
9394
#undef GetTempFileName
95+
#undef GetCurrentDirectory
9496
#undef GetFullPathName
9597
#undef CreateFile
9698
#undef GetFileAttributes
9799
#undef GetFileAttributesEx
100+
#undef DeleteFile
98101
#undef FindFirstFileEx
99102
#undef FindFirstFile
100103
#undef FindNextFile
101104
#undef CopyFile
102105
#undef CopyFileEx
103106
#undef MoveFile
107+
#undef MoveFileEx
104108
#undef CreateHardLink
105109
#undef CreateNamedPipe
106110
#undef WaitNamedPipe
@@ -139,6 +143,7 @@
139143
#define WszOpenEvent OpenEventW
140144
#define WszCreateWaitableTimer CreateWaitableTimerW
141145
#define WszCreateFileMapping CreateFileMappingW
146+
#define WszOpenFileMapping OpenFileMappingW
142147
#define WszGetModuleHandle GetModuleHandleW
143148
#define WszGetModuleHandleEx GetModuleHandleExW
144149
#define WszGetCommandLine GetCommandLineW
@@ -196,11 +201,13 @@
196201
#define WszCreateFile CreateFileWrapper
197202
#define WszGetFileAttributes GetFileAttributesWrapper
198203
#define WszGetFileAttributesEx GetFileAttributesExWrapper
204+
#define WszDeleteFile DeleteFileWrapper
199205

200206
//Can not use extended syntax
201207
#define WszGetFullPathName GetFullPathNameW
202208

203209
//Long Files will not work on these till redstone
210+
#define WszGetCurrentDirectory GetCurrentDirectoryWrapper
204211
#define WszGetTempPath GetTempPathWrapper
205212

206213
//APIS which have a buffer as an out parameter

src/coreclr/pal/inc/pal.h

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,35 @@ CopyFileW(
672672
#define CopyFile CopyFileA
673673
#endif
674674

675+
PALIMPORT
676+
BOOL
677+
PALAPI
678+
DeleteFileW(
679+
IN LPCWSTR lpFileName);
680+
681+
#ifdef UNICODE
682+
#define DeleteFile DeleteFileW
683+
#else
684+
#define DeleteFile DeleteFileA
685+
#endif
686+
687+
#define MOVEFILE_REPLACE_EXISTING 0x00000001
688+
#define MOVEFILE_COPY_ALLOWED 0x00000002
689+
690+
PALIMPORT
691+
BOOL
692+
PALAPI
693+
MoveFileExW(
694+
IN LPCWSTR lpExistingFileName,
695+
IN LPCWSTR lpNewFileName,
696+
IN DWORD dwFlags);
697+
698+
#ifdef UNICODE
699+
#define MoveFileEx MoveFileExW
700+
#else
701+
#define MoveFileEx MoveFileExA
702+
#endif
703+
675704
typedef struct _WIN32_FIND_DATAA {
676705
DWORD dwFileAttributes;
677706
FILETIME ftCreationTime;
@@ -828,6 +857,12 @@ PALAPI
828857
GetStdHandle(
829858
IN DWORD nStdHandle);
830859

860+
PALIMPORT
861+
BOOL
862+
PALAPI
863+
SetEndOfFile(
864+
IN HANDLE hFile);
865+
831866
PALIMPORT
832867
DWORD
833868
PALAPI
@@ -953,6 +988,19 @@ GetTempPathA(
953988
#define GetTempPath GetTempPathA
954989
#endif
955990

991+
PALIMPORT
992+
DWORD
993+
PALAPI
994+
GetCurrentDirectoryW(
995+
IN DWORD nBufferLength,
996+
OUT LPWSTR lpBuffer);
997+
998+
#ifdef UNICODE
999+
#define GetCurrentDirectory GetCurrentDirectoryW
1000+
#else
1001+
#define GetCurrentDirectory GetCurrentDirectoryA
1002+
#endif
1003+
9561004
PALIMPORT
9571005
HANDLE
9581006
PALAPI
@@ -1075,6 +1123,11 @@ DWORD
10751123
PALAPI
10761124
GetCurrentProcessId();
10771125

1126+
PALIMPORT
1127+
DWORD
1128+
PALAPI
1129+
GetCurrentSessionId();
1130+
10781131
PALIMPORT
10791132
HANDLE
10801133
PALAPI
@@ -2548,6 +2601,16 @@ SetThreadPriority(
25482601
IN HANDLE hThread,
25492602
IN int nPriority);
25502603

2604+
PALIMPORT
2605+
BOOL
2606+
PALAPI
2607+
GetThreadTimes(
2608+
IN HANDLE hThread,
2609+
OUT LPFILETIME lpCreationTime,
2610+
OUT LPFILETIME lpExitTime,
2611+
OUT LPFILETIME lpKernelTime,
2612+
OUT LPFILETIME lpUserTime);
2613+
25512614
PALIMPORT
25522615
HRESULT
25532616
PALAPI
@@ -2670,7 +2733,9 @@ typedef struct _CRITICAL_SECTION {
26702733
PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
26712734
PALIMPORT VOID PALAPI LeaveCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
26722735
PALIMPORT VOID PALAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection);
2736+
PALIMPORT BOOL PALAPI InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
26732737
PALIMPORT VOID PALAPI DeleteCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
2738+
PALIMPORT BOOL PALAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
26742739

26752740
#define SEM_FAILCRITICALERRORS 0x0001
26762741
#define SEM_NOOPENFILEERRORBOX 0x8000
@@ -2725,6 +2790,16 @@ CreateFileMappingW(
27252790
#define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
27262791
#define FILE_MAP_COPY SECTION_QUERY
27272792

2793+
PALIMPORT
2794+
HANDLE
2795+
PALAPI
2796+
OpenFileMappingW(
2797+
IN DWORD dwDesiredAccess,
2798+
IN BOOL bInheritHandle,
2799+
IN LPCWSTR lpName);
2800+
2801+
#define OpenFileMapping OpenFileMappingW
2802+
27282803
typedef INT_PTR (PALAPI_NOEXPORT *FARPROC)();
27292804

27302805
PALIMPORT
@@ -3914,6 +3989,16 @@ PALAPI
39143989
GetSystemInfo(
39153990
OUT LPSYSTEM_INFO lpSystemInfo);
39163991

3992+
PALIMPORT
3993+
BOOL
3994+
PALAPI
3995+
CreatePipe(
3996+
OUT PHANDLE hReadPipe,
3997+
OUT PHANDLE hWritePipe,
3998+
IN LPSECURITY_ATTRIBUTES lpPipeAttributes,
3999+
IN DWORD nSize
4000+
);
4001+
39174002
//
39184003
// NUMA related APIs
39194004
//
@@ -4132,7 +4217,6 @@ PALIMPORT int __cdecl iswspace(wint_t);
41324217
PALIMPORT int __cdecl iswxdigit(wint_t);
41334218
PALIMPORT wint_t __cdecl towupper(wint_t);
41344219
PALIMPORT wint_t __cdecl towlower(wint_t);
4135-
PALIMPORT int remove(const char*);
41364220
#endif // PAL_STDCPP_COMPAT
41374221

41384222
/* _TRUNCATE */
@@ -4404,6 +4488,8 @@ PALIMPORT int __cdecl PAL_ferror(PAL_FILE *);
44044488
PALIMPORT PAL_FILE * __cdecl PAL_fopen(const char *, const char *);
44054489
PALIMPORT int __cdecl PAL_setvbuf(PAL_FILE *stream, char *, int, size_t);
44064490

4491+
PALIMPORT int __cdecl _getw(PAL_FILE *);
4492+
PALIMPORT int __cdecl _putw(int, PAL_FILE *);
44074493
PALIMPORT PAL_FILE * __cdecl _fdopen(int, const char *);
44084494
PALIMPORT PAL_FILE * __cdecl _wfopen(const WCHAR *, const WCHAR *);
44094495

@@ -4443,6 +4529,7 @@ PALIMPORT DLLEXPORT int * __cdecl PAL_errno(int caller);
44434529
#endif // PAL_STDCPP_COMPAT
44444530

44454531
PALIMPORT DLLEXPORT char * __cdecl getenv(const char *);
4532+
PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);
44464533

44474534
#define ERANGE 34
44484535

src/coreclr/pal/inc/palprivate.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ PALAPI
3535
DeleteFileA(
3636
IN LPCSTR lpFileName);
3737

38+
PALIMPORT
39+
BOOL
40+
PALAPI
41+
MoveFileExA(
42+
IN LPCSTR lpExistingFileName,
43+
IN LPCSTR lpNewFileName,
44+
IN DWORD dwFlags);
45+
3846
PALIMPORT
3947
BOOL
4048
PALAPI
@@ -108,6 +116,13 @@ GetTempPathA(
108116
IN DWORD nBufferLength,
109117
OUT LPSTR lpBuffer);
110118

119+
PALIMPORT
120+
DWORD
121+
PALAPI
122+
GetCurrentDirectoryA(
123+
IN DWORD nBufferLength,
124+
OUT LPSTR lpBuffer);
125+
111126
PALIMPORT
112127
BOOL
113128
PALAPI
@@ -178,6 +193,15 @@ CompareFileTime(
178193
IN CONST FILETIME *lpFileTime1,
179194
IN CONST FILETIME *lpFileTime2);
180195

196+
/* These are from the <FCNTL.H> file in windows.
197+
They are needed for _open_osfhandle.*/
198+
#define _O_RDONLY 0x0000
199+
#define _O_APPEND 0x0008
200+
#define _O_TEXT 0x4000
201+
#define _O_BINARY 0x8000
202+
203+
PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);
204+
181205
#ifdef __cplusplus
182206
}
183207
#endif

0 commit comments

Comments
 (0)