| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -04:00
										 |  |  | namespace factor { | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -04:00
										 |  |  | void factor_vm::c_to_factor_toplevel(cell quot) { c_to_factor(quot); } | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -04:00
										 |  |  | void factor_vm::init_signals() { unix_init_signals(); } | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -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. */ | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -04:00
										 |  |  | const char* default_image_path() { | 
					
						
							|  |  |  |   const char* path = vm_executable_path(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!path) | 
					
						
							|  |  |  |     return "factor.image"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   int len = strlen(path); | 
					
						
							| 
									
										
										
										
											2016-03-23 07:17:38 -04:00
										 |  |  |   char* new_path = new char[len + SUFFIX_LEN + 1]; | 
					
						
							|  |  |  |   memcpy(new_path, path, len); | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -04:00
										 |  |  |   memcpy(new_path + len, SUFFIX, SUFFIX_LEN + 1); | 
					
						
							|  |  |  |   free(const_cast<char*>(path)); | 
					
						
							|  |  |  |   return new_path; | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-13 00:28:25 -04:00
										 |  |  | uint64_t nano_count() { | 
					
						
							| 
									
										
										
										
											2013-05-11 22:24:31 -04:00
										 |  |  |   struct timespec t; | 
					
						
							|  |  |  |   int ret = clock_gettime(CLOCK_MONOTONIC, &t); | 
					
						
							|  |  |  |   if (ret != 0) | 
					
						
							|  |  |  |     fatal_error("clock_gettime failed", 0); | 
					
						
							| 
									
										
										
										
											2013-05-13 00:53:47 -04:00
										 |  |  |   return (uint64_t)t.tv_sec * 1000000000 + t.tv_nsec; | 
					
						
							| 
									
										
										
										
											2009-11-18 05:20:05 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | } |