diff options
Diffstat (limited to 'Utilities/cmlibuv/src/unix/darwin.c')
-rw-r--r-- | Utilities/cmlibuv/src/unix/darwin.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Utilities/cmlibuv/src/unix/darwin.c b/Utilities/cmlibuv/src/unix/darwin.c index a7be0dd..62f04d3 100644 --- a/Utilities/cmlibuv/src/unix/darwin.c +++ b/Utilities/cmlibuv/src/unix/darwin.c @@ -280,14 +280,18 @@ static int uv__get_cpu_speed(uint64_t* speed) { NULL, 0); if (freq_ref) { - uint32_t freq; + const UInt8* freq_ref_ptr = pCFDataGetBytePtr(freq_ref); CFIndex len = pCFDataGetLength(freq_ref); - CFRange range; - range.location = 0; - range.length = len; + if (len == 8) + memcpy(speed, freq_ref_ptr, 8); + else if (len == 4) { + uint32_t v; + memcpy(&v, freq_ref_ptr, 4); + *speed = v; + } else { + *speed = 0; + } - pCFDataGetBytes(freq_ref, range, (UInt8*)&freq); - *speed = freq; pCFRelease(freq_ref); pCFRelease(data); break; |