Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8a13147
Remove PAL_Random
jkoritzinsky Oct 16, 2024
f96014a
Move the "COM minipal" APIs into the regular repo minipal and update …
jkoritzinsky Oct 16, 2024
5ccbb53
Remove direct CoCreateGuid usage from CoreCLR and instead use the min…
jkoritzinsky Oct 16, 2024
cbb3c4a
Remove CoTaskMemAlloc/Free usage from xplat code (and instead use the…
jkoritzinsky Oct 16, 2024
995c858
palrt is empty, so remove it.
jkoritzinsky Oct 17, 2024
75c421d
Use minipal_u16_strlen in more places.
jkoritzinsky Oct 17, 2024
4ab9fdf
Use minipal's random APIs instead of Mono having their own
jkoritzinsky Oct 17, 2024
d44224d
fixup! Use minipal_u16_strlen in more places.
jkoritzinsky Oct 17, 2024
2b4779b
Remove 'random' usage in eventpipe and unify all usages of the minipa…
jkoritzinsky Oct 17, 2024
40077d5
PR feedback
jkoritzinsky Oct 17, 2024
9408aa6
Link minipal to bcrypt and flow it so superpmi picks it up
jkoritzinsky Oct 17, 2024
aae4c86
Make the co-task-mem-alloc PAL just call malloc
jkoritzinsky Oct 17, 2024
9ccdb60
We're in C
jkoritzinsky Oct 17, 2024
676c988
Add casts for Windows
jkoritzinsky Oct 17, 2024
1be8d8a
Fix assert
jkoritzinsky Oct 18, 2024
4f39154
Remove u16_strlen from the CoreCLR minipal
jkoritzinsky Oct 21, 2024
040549d
PR feedback and fix dbgutil.cpp
jkoritzinsky Oct 21, 2024
7ab733a
Fix CoreCLR eventpipe runtime.
jkoritzinsky Oct 21, 2024
367612d
Fix windows build
jkoritzinsky Oct 22, 2024
f31bcfd
Move guid definitions out of the minipal and back to the CoreCLR PAL …
jkoritzinsky Oct 23, 2024
329434f
Fix include path now that we're in the PAL and not palrt
jkoritzinsky Oct 24, 2024
337fcef
Add rt include directory for guid.cpp
jkoritzinsky Oct 25, 2024
2d94d0a
Export GUID_NULL from the dac's copy of the PAL for the dbi.
jkoritzinsky Oct 25, 2024
460b8e5
Revert "Remove u16_strlen from the CoreCLR minipal"
jkoritzinsky Oct 29, 2024
a907e73
Merge branch 'more-minipal' of github.com:jkoritzinsky/runtime into m…
jkoritzinsky Oct 29, 2024
1f5573e
Merge branch 'main' into more-minipal
jkoritzinsky Oct 29, 2024
2ef0a5a
Go back to a CoTaskMemAlloc PAL
jkoritzinsky Oct 29, 2024
5f4df82
Use a prefixed name everywhere instead of shiming the Win32 API name …
jkoritzinsky Oct 29, 2024
c84060e
Fix target name change after merge
jkoritzinsky Oct 29, 2024
05d141b
Don't prefix the method but instead put the header in a subfolder.
jkoritzinsky Oct 30, 2024
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
4 changes: 0 additions & 4 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_H
add_subdirectory(utilcode)
add_subdirectory(inc)

if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(palrt)
endif(CLR_CMAKE_HOST_UNIX)

add_subdirectory(ilasm)
add_subdirectory(ildasm)
add_subdirectory(gcinfo)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ void CordbModule::CopyRemoteMetaData(

// Allocate space for the local copy of the metadata
// No need to zero out the memory since we'll fill it all here.
LPVOID pRawBuffer = CoTaskMemAlloc(buffer.cbSize);
LPVOID pRawBuffer = minipal_co_task_mem_alloc(buffer.cbSize);
if (pRawBuffer == NULL)
{
ThrowOutOfMemory();
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/debug/inc/dbgtransportsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#endif // !RIGHT_SIDE_COMPILE

#include <minipal/guid.h>

#if defined(FEATURE_DBGIPC_TRANSPORT_VM) || defined(FEATURE_DBGIPC_TRANSPORT_DI)

#include <twowaypipe.h>
Expand Down Expand Up @@ -519,7 +521,7 @@ class DbgTransportSession
// Struct defining the format of the data block sent with a SessionRequest.
struct SessionRequestData
{
GUID m_sSessionID; // Unique session ID. Treated as byte blob so no endian-ness
minipal_guid_t m_sSessionID; // Unique session ID. Treated as byte blob so no endian-ness
};

// Struct used to track a message that is being (or will soon be) sent but has not yet been acknowledged.
Expand Down Expand Up @@ -674,7 +676,7 @@ class DbgTransportSession
// Session ID randomly allocated by the right side and sent over in the SessionRequest message. This
// serves to disambiguate a re-send of the SessionRequest due to a network error versus a SessionRequest
// from a different debugger.
GUID m_sSessionID;
minipal_guid_t m_sSessionID;

// Lock used to synchronize sending messages and updating the session state. This ensures message bytes
// don't become interleaved on the transport connection, the send queue is updated consistently across
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/debug/shared/dbgtransportsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ HRESULT DbgTransportSession::Init(DebuggerIPCControlBlock *pDCB, AppDomainEnumer
// The RS randomly allocates a session ID which is sent to the LS in the SessionRequest message. In the
// case of network errors during session formation this allows the LS to tell SessionRequest re-sends from
// a new request from a different RS.
HRESULT hr = CoCreateGuid(&m_sSessionID);
if (FAILED(hr))
return hr;
if (!minipal_guid_v4_create(&m_sSessionID))
return E_FAIL;
#endif // RIGHT_SIDE_COMPILE


Expand Down
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ else(CLR_CMAKE_HOST_WIN32)
mscorrc
${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available
coreclrpal
palrt
coreclrminipal
${END_WHOLE_ARCHIVE}
)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ nativeStringResourceTable_mscorrc
#PAL_CloseProcessMemory
#PAL_ReadProcessMemory
#PAL_ProbeMemory
#PAL_Random
#PAL__wcstoui64
#PAL_wcstoul
#PAL_wcstod
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ if(CLR_CMAKE_HOST_WIN32)
elseif(CLR_CMAKE_HOST_UNIX)

list(APPEND COREDBI_LIBRARIES
palrt
# share the PAL in the dac module
mscordaccore
)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ else()
coreclrpal
${END_WHOLE_ARCHIVE}
mscorrc
palrt
)
endif(CLR_CMAKE_TARGET_WIN32)

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/dlls/mscorpe/pewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ HRESULT PEWriter::write(void ** ppImage)
size_t lSize = filePos;

// allocate the block we are handing back to the caller
void * pImage = (void *) ::CoTaskMemAlloc(lSize);
void * pImage = (void *) ::minipal_co_task_mem_alloc(lSize);
if (NULL == pImage)
{
return E_OUTOFMEMORY;
Expand Down Expand Up @@ -1626,7 +1626,7 @@ HRESULT PEWriter::write(void ** ppImage)
// make sure we wrote the exact numbmer of bytes expected
_ASSERTE(lSize == (size_t) (pCur - (char *)pImage));

// give pointer to memory image back to caller (who must free with ::CoTaskMemFree())
// give pointer to memory image back to caller (who must free with ::minipal_co_task_mem_free())
*ppImage = pImage;

// all done
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/ilasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ else()
list(APPEND ILASM_LINK_LIBRARIES
coreclrpal
mscorrc
palrt
coreclrminipal
)
endif(CLR_CMAKE_TARGET_WIN32)
Expand All @@ -116,7 +115,6 @@ if(CLR_CMAKE_HOST_UNIX)
utilcodestaticnohost
mscorrc
coreclrpal
palrt
${CMAKE_DL_LIBS}
)
else()
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/ilasm/assem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,20 +1064,11 @@ BOOL Assembler::EmitClass(Class *pClass)
LPCUTF8 szFullName;
WCHAR* wzFullName=&wzUniBuf[0];
HRESULT hr = E_FAIL;
GUID guid;
size_t L;
mdToken tok;

if(pClass == NULL) return FALSE;

hr = CoCreateGuid(&guid);
if (FAILED(hr))
{
printf("Unable to create GUID\n");
m_State = STATE_FAIL;
return FALSE;
}

if(pClass->m_pEncloser)
szFullName = strrchr(pClass->m_szFQN,NESTING_SEP) + 1;
else
Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/ilasm/portable_pdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ HRESULT PortablePdbWriter::Init(IMetaDataDispenserEx2* mdDispenser)
time_t now;
time(&now);
m_pdbStream.id.pdbTimeStamp = (ULONG)now;
hr = CoCreateGuid(&m_pdbStream.id.pdbGuid);

if (FAILED(hr)) goto exit;
if (!minipal_guid_v4_create(reinterpret_cast<minipal_guid_t*>(&m_pdbStream.id.pdbGuid)))
{
hr = E_FAIL;
goto exit;
}

hr = mdDispenser->DefinePortablePdbScope(
CLSID_CorMetaDataRuntime,
Expand Down Expand Up @@ -176,7 +178,7 @@ HRESULT PortablePdbWriter::DefineDocument(char* name, GUID* language)
mdDocument docToken = mdDocumentNil;

if (FAILED(hr = m_pdbEmitter->DefineDocument(
name, // will be tokenized
name, // will be tokenized
&hashAlgorithmUnknown,
hashValue,
cbHashValue,
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/ildasm/exe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ else()
list(APPEND ILDASM_LINK_LIBRARIES
coreclrpal
mscorrc
palrt
coreclrminipal
)
endif(CLR_CMAKE_HOST_WIN32)
Expand All @@ -105,7 +104,6 @@ if(CLR_CMAKE_HOST_UNIX)
${ILDASM_LINK_LIBRARIES}
mscorrc
coreclrpal
palrt
${CMAKE_DL_LIBS}
)
else()
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/inc/holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "staticcontract.h"
#include "volatile.h"
#include "palclr.h"
#include <minipal/memory.h>

#include <utility>
#include <type_traits>
Expand Down Expand Up @@ -969,7 +970,7 @@ template <typename TYPE>
FORCEINLINE void DeleteCoTaskMem(TYPE *value)
{
if (value)
CoTaskMemFree(value);
minipal_co_task_mem_free(value);
}

template<typename _TYPE>
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/md/compiler/regmeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "posterror.h"
#include "stgio.h"
#include "sstring.h"
#include <minipal/guid.h>

#include "mdinternalrw.h"

Expand Down Expand Up @@ -246,7 +247,7 @@ RegMeta::CreateNewMD()
ModuleRec *pModule;
GUID mvid;
IfFailGo(m_pStgdb->m_MiniMd.AddModuleRecord(&pModule, &iRecord));
IfFailGo(CoCreateGuid(&mvid));
IfFailGo(minipal_guid_v4_create(reinterpret_cast<minipal_guid_t*>(&mvid)) ? S_OK : E_FAIL);
IfFailGo(m_pStgdb->m_MiniMd.PutGuid(TBL_Module, ModuleRec::COL_Mvid, pModule, mvid));

// Add the dummy module typedef which we are using to parent global items.
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/md/enc/metamodelrw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "../compiler/importhelper.h"
#include "metadata.h"
#include "streamutil.h"
#include <minipal/guid.h>

#ifdef _MSC_VER
#pragma intrinsic(memcpy)
Expand Down Expand Up @@ -1196,7 +1197,7 @@ CMiniMdRW::SetOption(
PutCol(TBL_Module, ModuleRec::COL_EncBaseId, pMod, uVal);
*/
// Allocate a new GUID for EncId.
IfFailGo(CoCreateGuid(&encid));
IfFailGo(minipal_guid_v4_create(reinterpret_cast<minipal_guid_t*>(&encid)) ? S_OK : E_FAIL);
IfFailGo(PutGuid(TBL_Module, ModuleRec::COL_EncId, pMod, encid));
#else //!FEATURE_METADATA_EMIT
IfFailGo(E_INVALIDARG);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/md/enc/stgio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void StgIO::Close()
case STGIO_SHAREDMEM:
if (m_pBaseData != NULL)
{
CoTaskMemFree(m_pBaseData);
minipal_co_task_mem_free(m_pBaseData);
m_pBaseData = NULL;
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/md/inc/portablepdbmdds.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif

#include "corhdr.h"
#include <minipal/guid.h>

//-------------------------------------
//--- PDB stream data structure
Expand Down
8 changes: 3 additions & 5 deletions src/coreclr/minipal/Unix/dn-u16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ typedef char16_t WCHAR;

#include <dn-u16.h>
#include <string.h>
#include <minipal/strings.h>

size_t u16_strlen(const WCHAR* str)
{
size_t nChar = 0;
while (*str++)
nChar++;
return nChar;
return minipal_u16_strlen((CHAR16_T*)str);
}

int u16_strcmp(const WCHAR* str1, const WCHAR* str2)
Expand Down Expand Up @@ -192,4 +190,4 @@ uint64_t u16_strtoui64(const WCHAR* nptr, WCHAR** endptr, int base)
double u16_strtod(const WCHAR* nptr, WCHAR** endptr)
{
return PAL_wcstod(nptr, endptr);
}
}
7 changes: 0 additions & 7 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,6 @@ PALAPI
PAL_UnregisterModule(
IN HINSTANCE hInstance);

PALIMPORT
VOID
PALAPI
PAL_Random(
IN OUT LPVOID lpBuffer,
IN DWORD dwLength);

PALIMPORT
BOOL
PALAPI
Expand Down
31 changes: 0 additions & 31 deletions src/coreclr/pal/inc/rt/palrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ typedef union _ULARGE_INTEGER {
} ULARGE_INTEGER, *PULARGE_INTEGER;

/******************* OLE, BSTR, VARIANT *************************/

STDAPI_VIS(DLLEXPORT, LPVOID) CoTaskMemAlloc(SIZE_T cb);
STDAPI_VIS(DLLEXPORT, void) CoTaskMemFree(LPVOID pv);

typedef SHORT VARIANT_BOOL;
#define VARIANT_TRUE ((VARIANT_BOOL)-1)
#define VARIANT_FALSE ((VARIANT_BOOL)0)
Expand Down Expand Up @@ -1069,33 +1065,6 @@ typedef LONG (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
);
typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;

/******************** PAL RT APIs *******************************/

typedef struct _HSATELLITE *HSATELLITE;

EXTERN_C HSATELLITE PALAPI PAL_LoadSatelliteResourceW(LPCWSTR SatelliteResourceFileName);
EXTERN_C HSATELLITE PALAPI PAL_LoadSatelliteResourceA(LPCSTR SatelliteResourceFileName);
EXTERN_C BOOL PALAPI PAL_FreeSatelliteResource(HSATELLITE SatelliteResource);
EXTERN_C UINT PALAPI PAL_LoadSatelliteStringW(HSATELLITE SatelliteResource,
UINT uID,
LPWSTR lpBuffer,
UINT nBufferMax);
EXTERN_C UINT PALAPI PAL_LoadSatelliteStringA(HSATELLITE SatelliteResource,
UINT uID,
LPSTR lpBuffer,
UINT nBufferMax);

EXTERN_C HRESULT PALAPI PAL_CoCreateInstance(REFCLSID rclsid,
REFIID riid,
void **ppv);

// So we can have CoCreateInstance in most of the code base,
// instead of spreading around of if'def FEATURE_PALs for PAL_CoCreateInstance.
#define CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv) PAL_CoCreateInstance(rclsid, riid, ppv)

STDAPI
CoCreateGuid(OUT GUID * pguid);

/************** Byte swapping & unaligned access ******************/

#include <pal_endian.h>
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ set(SOURCES
misc/error.cpp
misc/errorstrings.cpp
misc/fmtmessage.cpp
misc/miscpalapi.cpp
misc/perfjitdump.cpp
misc/strutil.cpp
misc/sysinfo.cpp
Expand Down
Loading
Loading