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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

jkoritzinsky
Copy link
Member

Change usages of PAL_Random to instead use the minipal's random bytes APIs.

Move the remaining palrt APIs to the minipal to make them more easily usable outside of CoreCLR's PAL (and also to shrink the CoreCLR PAL). This work was spurred by #107961, where I realized that the set of Win32-like APIs that DNMD needs is equivalent to the set of Win32 API shims provided by palrt. To simplify things, I just decided to move the palrt implementations (with implementations that defer to the abstracted APIs on Windows) to the minipal and remove the palrt component.

Mostly extracted from #107961 when refactoring the new minipal APIs.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

{
#endif // __cplusplus

typedef struct minipal_guid__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
typedef struct minipal_guid__
typedef struct

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get a slightly better experience in debuggers by giving a name to the struct instead of just naming the typedef (without the name on the struct, you just get "anonymous struct" which is a little annoying).

src/native/minipal/memory.c Outdated Show resolved Hide resolved
src/coreclr/dlls/mscorpe/pewriter.cpp Outdated Show resolved Hide resolved
src/coreclr/dlls/mscorpe/pewriter.cpp Outdated Show resolved Hide resolved
src/coreclr/md/compiler/regmeta.cpp Outdated Show resolved Hide resolved
src/native/minipal/memory.c Outdated Show resolved Hide resolved
* @param str The null-terminated UTF-16 string.
* @return The length of the string.
*/
size_t minipal_u16_strlen(const CHAR16_T* str);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must be missing something but why not use wcslen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wcslen doesn't work on non-Windows as wchar_t on Unix platforms is 4-byte UTF-32, not 2-byte UTF-16.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just forward to wcslen on Windows.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be deleted and all callers switched to minipal_u16_strlen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants