| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | #include "master.hpp"
 | 
					
						
							| 
									
										
										
										
											2009-11-18 12:09:05 -05:00
										 |  |  | #include <time.h>
 | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | namespace factor | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-23 14:05:46 -04:00
										 |  |  | void factor_vm::c_to_factor_toplevel(cell quot) | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-01-05 21:47:36 -05:00
										 |  |  | 	c_to_factor(quot); | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-28 11:37:28 -04:00
										 |  |  | void factor_vm::init_signals() | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | { | 
					
						
							|  |  |  | 	unix_init_signals(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:33:35 -04:00
										 |  |  | void early_init() { } | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define SUFFIX ".image"
 | 
					
						
							|  |  |  | #define SUFFIX_LEN 6
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 22:17:20 -04:00
										 |  |  | /* You must delete[] the result yourself. */ | 
					
						
							| 
									
										
										
										
											2009-05-05 12:33:35 -04:00
										 |  |  | const char *default_image_path() | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | { | 
					
						
							|  |  |  | 	const char *path = vm_executable_path(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(!path) | 
					
						
							|  |  |  | 		return "factor.image"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-02 21:36:19 -04:00
										 |  |  | 	int len = strlen(path); | 
					
						
							| 
									
										
										
										
											2009-09-25 22:17:20 -04:00
										 |  |  | 	char *new_path = new char[PATH_MAX + SUFFIX_LEN + 1]; | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 	memcpy(new_path,path,len + 1); | 
					
						
							|  |  |  | 	memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1); | 
					
						
							| 
									
										
										
										
											2009-10-03 12:17:55 -04:00
										 |  |  | 	free(const_cast<char *>(path)); | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 	return new_path; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-18 16:58:48 -05:00
										 |  |  | u64 nano_count() | 
					
						
							| 
									
										
										
										
											2009-11-18 05:20:05 -05:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct timespec t; | 
					
						
							| 
									
										
										
										
											2010-04-11 23:26:11 -04:00
										 |  |  | 	int ret = clock_gettime(CLOCK_MONOTONIC,&t); | 
					
						
							| 
									
										
										
										
											2009-11-18 05:20:05 -05:00
										 |  |  | 	if(ret != 0) | 
					
						
							|  |  |  | 		fatal_error("clock_gettime failed", 0); | 
					
						
							|  |  |  | 	return (u64)t.tv_sec * 1000000000 + t.tv_nsec; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | } |