1 #import <Cocoa/Cocoa.h>
3 #include <mach/mach_time.h>
4 #include <sys/utsname.h>
11 void factor_vm::c_to_factor_toplevel(cell quot)
16 // Darwin 9 is 10.5, Darwin 10 is 10.6
17 // http://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
23 sscanf(u.release,"%d", &n);
25 std::cout << "Factor requires Mac OS X 10.5 or later.\n";
30 const char *vm_executable_path(void)
32 return [[[NSBundle mainBundle] executablePath] UTF8String];
35 const char *default_image_path(void)
37 NSBundle *bundle = [NSBundle mainBundle];
38 NSString *path = [bundle bundlePath];
39 NSString *executable = [[bundle executablePath] lastPathComponent];
40 NSString *image = [executable stringByAppendingString:@".image"];
44 if([path hasSuffix:@".app"] || [path hasSuffix:@".app/"])
46 NSFileManager *mgr = [NSFileManager defaultManager];
48 NSString *imageInBundle = [[path stringByAppendingPathComponent:@"Contents/Resources"] stringByAppendingPathComponent:image];
49 NSString *imageAlongBundle = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:image];
51 returnVal = ([mgr fileExistsAtPath:imageInBundle]
52 ? imageInBundle : imageAlongBundle);
55 returnVal = [path stringByAppendingPathComponent:image];
57 return [returnVal UTF8String];
60 void factor_vm::init_signals(void)
66 /* Amateurs at Apple: implement this function, properly! */
67 Protocol *objc_getProtocol(char *name)
69 if(strcmp(name,"NSTextInput") == 0)
70 return @protocol(NSTextInput);
77 u64 time = mach_absolute_time();
79 static u64 scaling_factor = 0;
82 mach_timebase_info_data_t info;
83 kern_return_t ret = mach_timebase_info(&info);
85 fatal_error("mach_timebase_info failed",ret);
86 scaling_factor = info.numer/info.denom;
89 return time * scaling_factor;