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

Remove PAL_Random and move palrt APIs into the minipal #108999

Merged
merged 30 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Remove u16_strlen from the CoreCLR minipal"
This reverts commit 4f39154.
  • Loading branch information
jkoritzinsky committed Oct 29, 2024
commit 460b8e5f3671c00555bd7bd659c2f783bad279f1
16 changes: 8 additions & 8 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ SplitFullName(_In_z_ PCWSTR fullName,
else
{
*params = NULL;
memberEnd = fullName + (minipal_u16_strlen((const CHAR16_T*)fullName) - 1);
memberEnd = fullName + (u16_strlen(fullName) - 1);
}

if (syntax != SPLIT_TYPE)
Expand Down Expand Up @@ -5680,7 +5680,7 @@ static int FormatCLRStubName(
// Compute the address as a string safely.
WCHAR addrString[Max64BitHexString + 1];
FormatInteger(addrString, ARRAY_SIZE(addrString), "%p", stubAddr);
size_t addStringLen = minipal_u16_strlen((const CHAR16_T*)addrString);
size_t addStringLen = u16_strlen(addrString);

// Compute maximum length, include the null terminator.
size_t formatName_MaxLen = ARRAY_SIZE(formatName_Prefix) // Include trailing null
Expand All @@ -5691,7 +5691,7 @@ static int FormatCLRStubName(
size_t stubManagedNameLen = 0;
if (stubNameMaybe != NULL)
{
stubManagedNameLen = minipal_u16_strlen((const CHAR16_T*)stubNameMaybe);
stubManagedNameLen = u16_strlen(stubNameMaybe);
formatName_MaxLen += ARRAY_SIZE(formatName_OpenBracket) - 1;
formatName_MaxLen += ARRAY_SIZE(formatName_CloseBracket) - 1;
}
Expand Down Expand Up @@ -6458,7 +6458,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
// It is possible that the module is in-memory. That is the wszFilePath here is empty.
// We will try to use the module name instead in this case for hosting debugger
// to find match.
if (minipal_u16_strlen((const CHAR16_T*)wszFilePath) == 0)
if (u16_strlen(wszFilePath) == 0)
{
mdImage->GetModuleFileNameHintForDAC().DacGetUnicode(cchFilePath, wszFilePath, &uniPathChars);
if (uniPathChars > cchFilePath)
Expand Down Expand Up @@ -7259,9 +7259,9 @@ STDAPI OutOfProcessExceptionEventCallback(_In_ PDWORD pContext,
return hr;
}

if ((pwszEventName == NULL) || (*pchSize <= minipal_u16_strlen((const CHAR16_T*)gmb.wzEventTypeName)))
if ((pwszEventName == NULL) || (*pchSize <= u16_strlen(gmb.wzEventTypeName)))
{
*pchSize = static_cast<DWORD>(minipal_u16_strlen((const CHAR16_T*)gmb.wzEventTypeName)) + 1;
*pchSize = static_cast<DWORD>(u16_strlen(gmb.wzEventTypeName)) + 1;
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}

Expand Down Expand Up @@ -7383,9 +7383,9 @@ STDAPI OutOfProcessExceptionEventSignatureCallback(_In_ PDWORD pContext,
// Return pwszName as an emptry string to let WER use localized version of "Parameter n"
*pwszName = W('\0');

if ((pwszValue == NULL) || (*pchValue <= minipal_u16_strlen((const CHAR16_T*)pwszBucketValues[dwIndex])))
if ((pwszValue == NULL) || (*pchValue <= u16_strlen(pwszBucketValues[dwIndex])))
{
*pchValue = static_cast<DWORD>(minipal_u16_strlen((const CHAR16_T*)pwszBucketValues[dwIndex]))+ 1;
*pchValue = static_cast<DWORD>(u16_strlen(pwszBucketValues[dwIndex]))+ 1;
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ HRESULT ClrDataAccess::EnumMemCLRStatic(IN CLRDataEnumMemoryFlags flags)
WCHAR* path = entryAssemblyPath;
if (path != NULL)
{
size_t pathLen = minipal_u16_strlen((const CHAR16_T*)path) + 1;
size_t pathLen = u16_strlen(path) + 1;

// Get the file name based on the last directory separator
const WCHAR* name = u16_strrchr(path, DIRECTORY_SEPARATOR_CHAR_W);
if (name != NULL)
{
name += 1;
size_t len = minipal_u16_strlen((const CHAR16_T*)name) + 1;
size_t len = u16_strlen(name) + 1;
wcscpy_s(path, len, name);

// Null out the rest of the buffer
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ ClrDataValue::GetString(

if (strLen)
{
*strLen = static_cast<ULONG32>(minipal_u16_strlen((const CHAR16_T*)msgStr) + 1);
*strLen = static_cast<ULONG32>(u16_strlen(msgStr) + 1);
}
status = StringCchCopy(str, bufLen, msgStr) == S_OK ?
S_OK : S_FALSE;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ ClrDataAccess::GetRegisterName(int regNum, unsigned int count, _Inout_updates_z_
const WCHAR callerPrefix[] = W("caller.");
// Include null terminator in prefixLen/regLen because wcscpy_s will fail otherwise
unsigned int prefixLen = (unsigned int)ARRAY_SIZE(callerPrefix);
unsigned int regLen = (unsigned int)minipal_u16_strlen((const CHAR16_T*)regs[regNum]) + 1;
unsigned int regLen = (unsigned int)u16_strlen(regs[regNum]) + 1;
unsigned int needed = (callerFrame ? prefixLen - 1 : 0) + regLen;
if (pNeeded)
*pNeeded = needed;
Expand Down Expand Up @@ -2140,7 +2140,7 @@ ClrDataAccess::GetFrameName(CLRDATA_ADDRESS vtable, unsigned int count, _Inout_u
else
{
// Turn from bytes to wide characters
unsigned int len = (unsigned int)minipal_u16_strlen((const CHAR16_T*)pszName);
unsigned int len = (unsigned int)u16_strlen(pszName);

if (frameName)
{
Expand Down Expand Up @@ -2614,7 +2614,7 @@ ClrDataAccess::GetAppDomainName(CLRDATA_ADDRESS addr, unsigned int count, _Inout
if (pAppDomain->m_friendlyName.IsValid())
{
LPCWSTR friendlyName = (LPCWSTR)pAppDomain->m_friendlyName;
size_t friendlyNameLen = minipal_u16_strlen((const CHAR16_T*)friendlyName);
size_t friendlyNameLen = u16_strlen(friendlyName);

if (pNeeded)
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ ClrDataAppDomain::GetName(
S_OK : S_FALSE;
if (nameLen)
{
size_t cchName = minipal_u16_strlen((const CHAR16_T*)rawName) + 1;
size_t cchName = u16_strlen(rawName) + 1;
if (FitsIn<ULONG32>(cchName))
{
*nameLen = (ULONG32) cchName;
Expand Down Expand Up @@ -4749,7 +4749,7 @@ ClrDataExceptionState::GetString(
status = StringCchCopy(str, bufLen, msgStr) == S_OK ? S_OK : S_FALSE;
if (strLen != NULL)
{
size_t cchName = minipal_u16_strlen((const CHAR16_T*)msgStr) + 1;
size_t cchName = u16_strlen(msgStr) + 1;
if (FitsIn<ULONG32>(cchName))
{
*strLen = (ULONG32) cchName;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/dbgutil/dbgutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <assert.h>
#include <stdio.h>
#include <memory>
#include <minipal/strings.h>
#include <dn-u16.h>
#include "corhlpr.h"

#ifdef HOST_WINDOWS
Expand Down Expand Up @@ -329,7 +329,7 @@ HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget,
DWORD* pNextLevelRva)
{
HRESULT hr = S_OK;
DWORD nameLength = (DWORD)minipal_u16_strlen((const CHAR16_T*)pwzName);
DWORD nameLength = (DWORD)u16_strlen(pwzName);
WCHAR entryName[50];
assert(nameLength < 50); // this implementation won't support matching a name longer
// than 50 characters. We only look up the hard coded name
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9619,7 +9619,7 @@ void Ls_Rs_StringBuffer::CopyLSDataToRS(ICorDebugDataTarget * pTarget)

// Now we know it's safe to call u16_strlen. The buffer is local, so we know the pages are there.
// And we know there's a null capping the max length of the string.
SIZE_T dwActualLenWithNull = minipal_u16_strlen((const CHAR16_T*)pString) + 1;
SIZE_T dwActualLenWithNull = u16_strlen(pString) + 1;
if (dwActualLenWithNull != dwExpectedLenWithNull)
{
ThrowHR(CORDBG_E_TARGET_INCONSISTENT);
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/di/publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ CorpubProcess::CorpubProcess(DWORD dwProcessId,
if (ret > 0)
{
// Recompute string length because we don't know if 'ret' is in bytes or char.
SIZE_T len = minipal_u16_strlen((const CHAR16_T*)szName) + 1;
SIZE_T len = u16_strlen(szName) + 1;
m_szProcessName = new (nothrow) WCHAR[len];
if (m_szProcessName != NULL)
{
Expand Down Expand Up @@ -602,7 +602,7 @@ HRESULT AllocateAndReadRemoteString(
if (SUCCEEDED(hr))
{
// Ensure that the string we just read is actually null terminated.
// We can't call minipal_u16_strlen((const CHAR16_T*)) on it yet, since that may AV on a non-null terminated string.
// We can't call u16_strlen() on it yet, since that may AV on a non-null terminated string.
WCHAR * pString = *ppNewLocalBuffer;

if (pString[ceSize - 1] == W('\0'))
Expand All @@ -612,7 +612,7 @@ HRESULT AllocateAndReadRemoteString(
}
pString[ceSize - 1] = W('\0');

SIZE_T ceTestLen = minipal_u16_strlen((const CHAR16_T*)pString);
SIZE_T ceTestLen = u16_strlen(pString);
if (ceTestLen == ceSize - 1)
{
// String was not previously null-terminated.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rsmda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ HRESULT CordbMDA::QueryInterface(REFIID riid, void **ppInterface)
HRESULT CopyOutString(LPCWSTR pInputString, ULONG32 cchName, ULONG32 * pcchName, _Out_writes_to_opt_(cchName, *pcchName) WCHAR szName[])
{
_ASSERTE(pInputString != NULL);
ULONG32 len = (ULONG32) minipal_u16_strlen((const CHAR16_T*)pInputString) + 1;
ULONG32 len = (ULONG32) u16_strlen(pInputString) + 1;

if (cchName == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10205,7 +10205,7 @@ HRESULT CordbEval::NewString(LPCWSTR string)
{
PUBLIC_API_ENTRY(this);
FAIL_IF_NEUTERED(this);
return NewStringWithLength(string, (UINT)minipal_u16_strlen((const CHAR16_T*)string));
return NewStringWithLength(string, (UINT)u16_strlen(string));
}

//---------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/di/symbolinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ STDMETHODIMP SymbolInfo::GetTypeDefProps ( // S_OK or error.
*pdwTypeDefFlags=classInfo->flags;


SIZE_T cch=minipal_u16_strlen((const CHAR16_T*)classInfo->wszName.GetUnicode())+1;
SIZE_T cch=u16_strlen(classInfo->wszName)+1;
if (cch > UINT32_MAX)
return E_UNEXPECTED;
*pchTypeDef=(ULONG)cch;
Expand Down Expand Up @@ -309,7 +309,7 @@ STDMETHODIMP SymbolInfo::GetMethodProps (


*pClass=m_LastMethod.cls;
SIZE_T cch=minipal_u16_strlen((const CHAR16_T*)m_LastMethod.wszName.GetUnicode())+1;
SIZE_T cch=u16_strlen(m_LastMethod.wszName)+1;
if(cch > UINT32_MAX)
return E_UNEXPECTED;
*pchMethod=(ULONG)cch;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/inc/dbgappdomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct AppDomainInfo
else
m_szAppDomainName = W("<NoName>");

m_iNameLengthInBytes = (int) (minipal_u16_strlen((const CHAR16_T*)m_szAppDomainName) + 1) * sizeof(WCHAR);
m_iNameLengthInBytes = (int) (u16_strlen(m_szAppDomainName) + 1) * sizeof(WCHAR);
}
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/inc/dbgipcevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ template <int nMaxLengthIncludingNull>
class MSLAYOUT EmbeddedIPCString
{
public:
// Set, caller responsibility that minipal_u16_strlen((const CHAR16_T*)pData) < nMaxLengthIncludingNull
// Set, caller responsibility that u16_strlen(pData) < nMaxLengthIncludingNull
void SetString(const WCHAR * pData)
{
// If the string doesn't fit into the buffer, that's an issue (and so this is a real
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/inc/ddmarshalutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class WriteBuffer : public BaseBuffer
if (!fIsNull)
{
_ASSERTE(pString != NULL);
DWORD len = (DWORD) minipal_u16_strlen((const CHAR16_T*)pString);
DWORD len = (DWORD) u16_strlen(pString);
DWORD cbCopy = (len + 1) * sizeof(WCHAR);

EnsureSize(cbCopy);
Expand Down Expand Up @@ -179,7 +179,7 @@ class ReadBuffer : public BaseBuffer
else
{
const WCHAR * pString = (WCHAR*) &m_pBuffer[m_idx];
DWORD len = (DWORD) minipal_u16_strlen((const CHAR16_T*)pString);
DWORD len = (DWORD) u16_strlen(pString);
m_idx += (len + 1) * sizeof(WCHAR); // skip past null
_ASSERTE(m_idx <= m_size);
return pString;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/shared/stringcopyholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ HRESULT StringCopyHolder::AssignCopy(const WCHAR * pStringSrc)
}
else
{
SIZE_T cchLen = minipal_u16_strlen((const CHAR16_T*)pStringSrc) + 1;
SIZE_T cchLen = u16_strlen(pStringSrc) + 1;
m_szData = new (nothrow) WCHAR[cchLen];
if (m_szData == NULL)
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ HRESULT CeeFileGenWriter::setOutputFileName(_In_ LPWSTR fileName)
{
if (m_outputFileName)
delete[] m_outputFileName;
size_t len = minipal_u16_strlen((const CHAR16_T*)fileName) + 1;
size_t len = u16_strlen(fileName) + 1;
m_outputFileName = (LPWSTR)new (nothrow) WCHAR[len];
TESTANDRETURN(m_outputFileName!=NULL, E_OUTOFMEMORY);
wcscpy_s(m_outputFileName, len, fileName);
Expand All @@ -477,7 +477,7 @@ HRESULT CeeFileGenWriter::setResourceFileName(_In_ LPWSTR fileName)
{
if (m_resourceFileName)
delete[] m_resourceFileName;
size_t len = minipal_u16_strlen((const CHAR16_T*)fileName) + 1;
size_t len = u16_strlen(fileName) + 1;
m_resourceFileName = (LPWSTR)new (nothrow) WCHAR[len];
TESTANDRETURN(m_resourceFileName!=NULL, E_OUTOFMEMORY);
wcscpy_s(m_resourceFileName, len, fileName);
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/ilasm/asmman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ BinStr* BinStrToUnicode(BinStr* pSource, bool Swap)
{
memset(wz,0,L);
MultiByteToWideChar(g_uCodePage,0,pb,-1,wz,l);
tmp->remove(L-(DWORD)minipal_u16_strlen((const CHAR16_T*)wz)*sizeof(WCHAR));
tmp->remove(L-(DWORD)u16_strlen(wz)*sizeof(WCHAR));
#if BIGENDIAN
if (Swap)
SwapStringLength(wz, (DWORD)minipal_u16_strlen((const CHAR16_T*)wz));
SwapStringLength(wz, (DWORD)u16_strlen(wz));
#endif
delete pSource;
}
Expand Down Expand Up @@ -996,8 +996,8 @@ HRESULT AsmMan::EmitManifest()
else
{
m_dwMResSizeTotal += m_dwMResSize[m_dwMResNum]+sizeof(DWORD);
m_wzMResName[m_dwMResNum] = new WCHAR[minipal_u16_strlen((const CHAR16_T*)wzFileName)+1];
wcscpy_s(m_wzMResName[m_dwMResNum],minipal_u16_strlen((const CHAR16_T*)wzFileName)+1,wzFileName);
m_wzMResName[m_dwMResNum] = new WCHAR[u16_strlen(wzFileName)+1];
wcscpy_s(m_wzMResName[m_dwMResNum],u16_strlen(wzFileName)+1,wzFileName);
m_fMResNew[m_dwMResNum] = TRUE;
m_dwMResNum++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/ilasm/assem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ BOOL Assembler::EmitClass(Class *pClass)

MultiByteToWideChar(g_uCodePage,0,szFullName,-1,wzFullName,dwUniBuf);

L = minipal_u16_strlen((const CHAR16_T*)wzFullName);
L = u16_strlen(wzFullName);
if((L==0)||(wzFullName[L-1]==L'.')) // Missing class name!
{
wcscat_s(wzFullName,dwUniBuf,W("$UNNAMED_TYPE$"));
Expand Down
Loading