Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Reduce CoreCLR PAL" #76860

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ nativeStringResourceTable_mscorrc
#CloseHandle
#DebugBreak
#DeleteCriticalSection
#DeleteFileW
#DuplicateHandle
#EnterCriticalSection
#FindClose
Expand All @@ -111,6 +112,7 @@ nativeStringResourceTable_mscorrc
#FreeLibrary
#FileTimeToSystemTime
#GetACP
#GetCurrentDirectoryW
#GetCurrentProcess
#GetCurrentProcessId
#GetCurrentThreadId
Expand Down Expand Up @@ -139,6 +141,7 @@ nativeStringResourceTable_mscorrc
#LoadLibraryExW
#MapViewOfFile
#MapViewOfFileEx
#MoveFileExW
#MultiByteToWideChar
#OpenProcess
#OutputDebugStringW
Expand Down
12 changes: 2 additions & 10 deletions src/coreclr/ilasm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,16 +846,8 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv)
*pc = W('.');
}
wcscpy_s(pc+1,4,W("PDB"));

#ifdef TARGET_WINDOWS
_wremove(wzOutputFilename);
#else
MAKE_UTF8PTR_FROMWIDE_NOTHROW(szOutputFilename, wzOutputFilename);
if (szOutputFilename != NULL)
{
remove(szOutputFilename);
}
#endif
#undef DeleteFileW
DeleteFileW(wzOutputFilename);
}
if (exitval == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DisableStarvationDetection, W("Thre
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DebugBreakOnWorkerStarvation, W("ThreadPool_DebugBreakOnWorkerStarvation"), 0, "Breaks into the debugger if the ThreadPool detects work queue starvation")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_EnableWorkerTracking, W("ThreadPool_EnableWorkerTracking"), 0, "Enables extra expensive tracking of how many workers threads are working simultaneously")
#ifdef TARGET_ARM64
// Spinning scheme is currently different on ARM64
// Spinning scheme is currently different on ARM64, see CLRLifoSemaphore::Wait(DWORD, UINT32, UINT32)
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")
#else // !TARGET_ARM64
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")
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/inc/holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,14 @@ typedef Wrapper<HANDLE, DoNothing<HANDLE>, VoidFindClose, (UINT_PTR) -1> FindHan

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

#ifdef WszDeleteFile
// Deletes a file with the specified path. Do not use if you care about failures
// deleting the file, as failures are ignored by VoidDeleteFile.
FORCEINLINE void VoidDeleteFile(LPCWSTR wszFilePath) { WszDeleteFile(wszFilePath); }
typedef Wrapper<LPCWSTR, DoNothing<LPCWSTR>, VoidDeleteFile, NULL> DeleteFileHolder;
#endif // WszDeleteFile


//-----------------------------------------------------------------------------
// Misc holders
//-----------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/inc/longfilepathwrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ GetFileAttributesExWrapper(
_In_ GET_FILEEX_INFO_LEVELS fInfoLevelId,
_Out_writes_bytes_(sizeof(WIN32_FILE_ATTRIBUTE_DATA)) LPVOID lpFileInformation
);
BOOL
DeleteFileWrapper(
_In_ LPCWSTR lpFileName
);

#ifndef HOST_UNIX
BOOL
Expand Down Expand Up @@ -62,6 +66,10 @@ DWORD WINAPI GetTempPathWrapper(
SString& lpBuffer
);

DWORD WINAPI GetCurrentDirectoryWrapper(
SString& lpBuffer
);

DWORD
GetModuleFileNameWrapper(
_In_opt_ HMODULE hModule,
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/inc/winwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#undef OpenSemaphore
#undef CreateWaitableTimer
#undef CreateFileMapping
#undef OpenFileMapping
#undef LoadLibrary
#undef LoadLibraryEx
#undef GetModuleFileName
Expand All @@ -91,16 +92,19 @@
#undef GetSystemDirectory
#undef GetTempPath
#undef GetTempFileName
#undef GetCurrentDirectory
#undef GetFullPathName
#undef CreateFile
#undef GetFileAttributes
#undef GetFileAttributesEx
#undef DeleteFile
#undef FindFirstFileEx
#undef FindFirstFile
#undef FindNextFile
#undef CopyFile
#undef CopyFileEx
#undef MoveFile
#undef MoveFileEx
#undef CreateHardLink
#undef CreateNamedPipe
#undef WaitNamedPipe
Expand Down Expand Up @@ -139,6 +143,7 @@
#define WszOpenEvent OpenEventW
#define WszCreateWaitableTimer CreateWaitableTimerW
#define WszCreateFileMapping CreateFileMappingW
#define WszOpenFileMapping OpenFileMappingW
#define WszGetModuleHandle GetModuleHandleW
#define WszGetModuleHandleEx GetModuleHandleExW
#define WszGetCommandLine GetCommandLineW
Expand Down Expand Up @@ -196,11 +201,13 @@
#define WszCreateFile CreateFileWrapper
#define WszGetFileAttributes GetFileAttributesWrapper
#define WszGetFileAttributesEx GetFileAttributesExWrapper
#define WszDeleteFile DeleteFileWrapper

//Can not use extended syntax
#define WszGetFullPathName GetFullPathNameW

//Long Files will not work on these till redstone
#define WszGetCurrentDirectory GetCurrentDirectoryWrapper
#define WszGetTempPath GetTempPathWrapper

//APIS which have a buffer as an out parameter
Expand Down
89 changes: 88 additions & 1 deletion src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,35 @@ CopyFileW(
#define CopyFile CopyFileA
#endif

PALIMPORT
BOOL
PALAPI
DeleteFileW(
IN LPCWSTR lpFileName);

#ifdef UNICODE
#define DeleteFile DeleteFileW
#else
#define DeleteFile DeleteFileA
#endif

#define MOVEFILE_REPLACE_EXISTING 0x00000001
#define MOVEFILE_COPY_ALLOWED 0x00000002

PALIMPORT
BOOL
PALAPI
MoveFileExW(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName,
IN DWORD dwFlags);

#ifdef UNICODE
#define MoveFileEx MoveFileExW
#else
#define MoveFileEx MoveFileExA
#endif

typedef struct _WIN32_FIND_DATAA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
Expand Down Expand Up @@ -828,6 +857,12 @@ PALAPI
GetStdHandle(
IN DWORD nStdHandle);

PALIMPORT
BOOL
PALAPI
SetEndOfFile(
IN HANDLE hFile);

PALIMPORT
DWORD
PALAPI
Expand Down Expand Up @@ -953,6 +988,19 @@ GetTempPathA(
#define GetTempPath GetTempPathA
#endif

PALIMPORT
DWORD
PALAPI
GetCurrentDirectoryW(
IN DWORD nBufferLength,
OUT LPWSTR lpBuffer);

#ifdef UNICODE
#define GetCurrentDirectory GetCurrentDirectoryW
#else
#define GetCurrentDirectory GetCurrentDirectoryA
#endif

PALIMPORT
HANDLE
PALAPI
Expand Down Expand Up @@ -1075,6 +1123,11 @@ DWORD
PALAPI
GetCurrentProcessId();

PALIMPORT
DWORD
PALAPI
GetCurrentSessionId();

PALIMPORT
HANDLE
PALAPI
Expand Down Expand Up @@ -2548,6 +2601,16 @@ SetThreadPriority(
IN HANDLE hThread,
IN int nPriority);

PALIMPORT
BOOL
PALAPI
GetThreadTimes(
IN HANDLE hThread,
OUT LPFILETIME lpCreationTime,
OUT LPFILETIME lpExitTime,
OUT LPFILETIME lpKernelTime,
OUT LPFILETIME lpUserTime);

PALIMPORT
HRESULT
PALAPI
Expand Down Expand Up @@ -2670,7 +2733,9 @@ typedef struct _CRITICAL_SECTION {
PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
PALIMPORT VOID PALAPI LeaveCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
PALIMPORT VOID PALAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection);
PALIMPORT BOOL PALAPI InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
PALIMPORT VOID PALAPI DeleteCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
PALIMPORT BOOL PALAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);

#define SEM_FAILCRITICALERRORS 0x0001
#define SEM_NOOPENFILEERRORBOX 0x8000
Expand Down Expand Up @@ -2725,6 +2790,16 @@ CreateFileMappingW(
#define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
#define FILE_MAP_COPY SECTION_QUERY

PALIMPORT
HANDLE
PALAPI
OpenFileMappingW(
IN DWORD dwDesiredAccess,
IN BOOL bInheritHandle,
IN LPCWSTR lpName);

#define OpenFileMapping OpenFileMappingW

typedef INT_PTR (PALAPI_NOEXPORT *FARPROC)();

PALIMPORT
Expand Down Expand Up @@ -3914,6 +3989,16 @@ PALAPI
GetSystemInfo(
OUT LPSYSTEM_INFO lpSystemInfo);

PALIMPORT
BOOL
PALAPI
CreatePipe(
OUT PHANDLE hReadPipe,
OUT PHANDLE hWritePipe,
IN LPSECURITY_ATTRIBUTES lpPipeAttributes,
IN DWORD nSize
);

//
// NUMA related APIs
//
Expand Down Expand Up @@ -4132,7 +4217,6 @@ PALIMPORT int __cdecl iswspace(wint_t);
PALIMPORT int __cdecl iswxdigit(wint_t);
PALIMPORT wint_t __cdecl towupper(wint_t);
PALIMPORT wint_t __cdecl towlower(wint_t);
PALIMPORT int remove(const char*);
#endif // PAL_STDCPP_COMPAT

/* _TRUNCATE */
Expand Down Expand Up @@ -4404,6 +4488,8 @@ PALIMPORT int __cdecl PAL_ferror(PAL_FILE *);
PALIMPORT PAL_FILE * __cdecl PAL_fopen(const char *, const char *);
PALIMPORT int __cdecl PAL_setvbuf(PAL_FILE *stream, char *, int, size_t);

PALIMPORT int __cdecl _getw(PAL_FILE *);
PALIMPORT int __cdecl _putw(int, PAL_FILE *);
PALIMPORT PAL_FILE * __cdecl _fdopen(int, const char *);
PALIMPORT PAL_FILE * __cdecl _wfopen(const WCHAR *, const WCHAR *);

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

PALIMPORT DLLEXPORT char * __cdecl getenv(const char *);
PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);

#define ERANGE 34

Expand Down
24 changes: 24 additions & 0 deletions src/coreclr/pal/inc/palprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ PALAPI
DeleteFileA(
IN LPCSTR lpFileName);

PALIMPORT
BOOL
PALAPI
MoveFileExA(
IN LPCSTR lpExistingFileName,
IN LPCSTR lpNewFileName,
IN DWORD dwFlags);

PALIMPORT
BOOL
PALAPI
Expand Down Expand Up @@ -108,6 +116,13 @@ GetTempPathA(
IN DWORD nBufferLength,
OUT LPSTR lpBuffer);

PALIMPORT
DWORD
PALAPI
GetCurrentDirectoryA(
IN DWORD nBufferLength,
OUT LPSTR lpBuffer);

PALIMPORT
BOOL
PALAPI
Expand Down Expand Up @@ -178,6 +193,15 @@ CompareFileTime(
IN CONST FILETIME *lpFileTime1,
IN CONST FILETIME *lpFileTime2);

/* These are from the <FCNTL.H> file in windows.
They are needed for _open_osfhandle.*/
#define _O_RDONLY 0x0000
#define _O_APPEND 0x0008
#define _O_TEXT 0x4000
#define _O_BINARY 0x8000

PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);

#ifdef __cplusplus
}
#endif
Expand Down
Loading