summaryrefslogtreecommitdiff
path: root/src/palrt
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2018-03-06 02:21:09 +0100
committerGitHub <noreply@github.com>2018-03-06 02:21:09 +0100
commit76245a33daf1e4a8dc724e9b7fd712bd41a7aee0 (patch)
tree5067dae50136e8caca443e2d749814e05f653e3f /src/palrt
parenta2628fc507df0c011383dd0c275bfb0d51bcd060 (diff)
downloadcoreclr-76245a33daf1e4a8dc724e9b7fd712bd41a7aee0.tar.gz
coreclr-76245a33daf1e4a8dc724e9b7fd712bd41a7aee0.tar.bz2
coreclr-76245a33daf1e4a8dc724e9b7fd712bd41a7aee0.zip
Remove libuuid usage (#16643)
* Remove libuuid usage This change removes dependency on the libuuid library that is used for GUID creation only. It implements it using a random generator instead. It also modifies return type of PAL_Random to VOID since it was always returning TRUE and none of the existing callers were checking it. 1. Port the GUID creation to managed code. 2. Modify the PAL_Random to have 6 times better perf so that the perf of the CoCreateGuid that is used in the native runtime doesn't degrade that much w.r.t the previous state when the libuuid was used. 3. Use Interop.GetRandomBytes on Unix and fix Windows
Diffstat (limited to 'src/palrt')
-rw-r--r--src/palrt/guid.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/palrt/guid.cpp b/src/palrt/guid.cpp
index bd782c8502..14cd3bb490 100644
--- a/src/palrt/guid.cpp
+++ b/src/palrt/guid.cpp
@@ -24,3 +24,25 @@ DEFINE_GUID(IID_IClassFactory, 0x00000001, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x0
// objidl.idl
DEFINE_GUID(IID_ISequentialStream, 0x0c733a30, 0x2a1c, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
DEFINE_GUID(IID_IStream, 0x0000000c, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
+
+// Create a random guid based on the https://www.ietf.org/rfc/rfc4122.txt
+STDAPI
+CoCreateGuid(OUT GUID * pguid)
+{
+ PAL_Random(pguid, sizeof(GUID));
+
+ static const USHORT VersionMask = 0xF000;
+ static const USHORT RandomGuidVersion = 0x4000;
+
+ static const BYTE ClockSeqHiAndReservedMask = 0xC0;
+ static const BYTE ClockSeqHiAndReservedValue = 0x80;
+
+ // Modify bits indicating the type of the GUID
+
+ // time_hi_and_version
+ pguid->Data3 = (pguid->Data3 & ~VersionMask) | RandomGuidVersion;
+ // clock_seq_hi_and_reserved
+ pguid->Data4[0] = (pguid->Data4[0] & ~ClockSeqHiAndReservedMask) | ClockSeqHiAndReservedValue;
+
+ return S_OK;
+}