From 8020dcf385dc65ab8f69b4d26334acb65a985da8 Mon Sep 17 00:00:00 2001 From: Yuval Dolev Date: Sun, 29 Dec 2019 00:11:34 +0200 Subject: [PATCH] Implemented system_now_time. --- platform_mac/mac_4ed_functions.mm | 12 +++++++++--- platform_mac/mac_4ed_old.m | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/platform_mac/mac_4ed_functions.mm b/platform_mac/mac_4ed_functions.mm index 291e3061..a59fbad1 100644 --- a/platform_mac/mac_4ed_functions.mm +++ b/platform_mac/mac_4ed_functions.mm @@ -56,7 +56,7 @@ system_get_canonical_sig(){ [[NSString alloc] initWithBytes:name.data length:name.size encoding:NSUTF8StringEncoding]; NSString *standardized_path_ns_str = [path_ns_str stringByStandardizingPath]; - String_Const_u8 standardized_path = mac_SCu8((u8*)[standardized_path_ns_str UTF8String],[standardized_path_ns_str lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); + String_Const_u8 standardized_path = SCu8((u8*)[standardized_path_ns_str UTF8String],[standardized_path_ns_str lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); String_Const_u8 result = push_string_copy(arena, standardized_path); @@ -361,9 +361,15 @@ system_get_proc_sig(){ function system_now_time_sig(){ - u64 result = 0; + u64 now = mach_absolute_time(); - NotImplemented; + // NOTE(yuval): Elapsed nanoseconds calculation + u64 result = (u64)(((f32)now) * + ((f32)mac_vars.timebase_info.numer) / + ((f32)mac_vars.timebase_info.denom)); + + // NOTE(yuval): Conversion to useconds + result *= 1.0E-3; return(result); } diff --git a/platform_mac/mac_4ed_old.m b/platform_mac/mac_4ed_old.m index ebadc1ca..fad0565e 100644 --- a/platform_mac/mac_4ed_old.m +++ b/platform_mac/mac_4ed_old.m @@ -814,9 +814,9 @@ osx_list_loadable_fonts(void){ NSString *font_n = fonts[i]; char *font_n_c = (char*)[font_n UTF8String]; NSFont *font = [font_manager - fontWithFamily:font_n - traits:NSUnboldFontMask|NSUnitalicFontMask - weight:5 + fontWithFamily:font_n + traits:NSUnboldFontMask|NSUnitalicFontMask + weight:5 size:12]; NSString *path = get_font_path(font); char *path_c = 0;