factor/vm/os-genunix.cpp

48 lines
828 B
C++
Raw Normal View History

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
{
c_to_factor(quot);
2009-05-02 05:04:19 -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
/* 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);
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
u64 nano_count()
{
struct timespec t;
int ret = clock_gettime(CLOCK_MONOTONIC,&t);
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
}