Implemented system_now_time.

This commit is contained in:
Yuval Dolev 2019-12-29 00:11:34 +02:00
parent a91158ebf0
commit 8020dcf385
2 changed files with 12 additions and 6 deletions

View File

@ -56,7 +56,7 @@ system_get_canonical_sig(){
[[NSString alloc] initWithBytes:name.data length:name.size encoding:NSUTF8StringEncoding]; [[NSString alloc] initWithBytes:name.data length:name.size encoding:NSUTF8StringEncoding];
NSString *standardized_path_ns_str = [path_ns_str stringByStandardizingPath]; 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); String_Const_u8 result = push_string_copy(arena, standardized_path);
@ -361,9 +361,15 @@ system_get_proc_sig(){
function function
system_now_time_sig(){ 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); return(result);
} }

View File

@ -814,9 +814,9 @@ osx_list_loadable_fonts(void){
NSString *font_n = fonts[i]; NSString *font_n = fonts[i];
char *font_n_c = (char*)[font_n UTF8String]; char *font_n_c = (char*)[font_n UTF8String];
NSFont *font = [font_manager NSFont *font = [font_manager
fontWithFamily:font_n fontWithFamily:font_n
traits:NSUnboldFontMask|NSUnitalicFontMask traits:NSUnboldFontMask|NSUnitalicFontMask
weight:5 weight:5
size:12]; size:12];
NSString *path = get_font_path(font); NSString *path = get_font_path(font);
char *path_c = 0; char *path_c = 0;