#include <OSUtils.h>#include "sl.h"#include "timefuncs.h" doublesec_realtime(void){ struct timeval now; if(gettimeofday(&now, nil) != 0) return 0.0; return (double)now.tv_sec + (double)now.tv_usec/1.0e6;} /* * nsec() is wallclock and can be adjusted by timesync * so need to use cycles() instead, but fall back to * nsec() in case we can't */u64intnanosec_monotonic(void){ return 0;} voidtimestr(double s, char *buf, int sz){ USED(s); USED(sz); buf[0] = 0;} doubleparsetime(const char *s){ USED(s); return 0.0;} voidsleep_ms(int ms){ USED(ms);} intftruncate(int f, soffset sz){ USED(f); USED(sz); return -1;} char *getcwd(char *buf, usize len){ USED(buf); USED(len); return nil;} intchdir(const char *path){ USED(path); return -1;} intaccess(const char *path, int amode){ USED(path); USED(amode); return -1;} voidsys_init(void){} char os_version[10]; static const u8int boot[] = {#include "sl.boot.h"}; intmain(int argc, char **argv){ static SysEnvRec r; memset(&r, 0, sizeof(r)); SysEnvirons(2, &r); snprintf( os_version, sizeof(boot), "%d.%d.%d", r.systemVersion>>8, (r.systemVersion>>4)&0xf, (r.systemVersion>>0)&0xf ); slmain(boot, sizeof(boot), argc, argv);}
#include <OSUtils.h>
#include "sl.h"
#include "timefuncs.h"
double
sec_realtime(void)
{
struct timeval now;
if(gettimeofday(&now, nil) != 0)
return 0.0;
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
}
/*
* nsec() is wallclock and can be adjusted by timesync
* so need to use cycles() instead, but fall back to
* nsec() in case we can't
*/
u64int
nanosec_monotonic(void)
{
return 0;
}
void
timestr(double s, char *buf, int sz)
{
USED(s); USED(sz);
buf[0] = 0;
}
double
parsetime(const char *s)
{
USED(s);
return 0.0;
}
void
sleep_ms(int ms)
{
USED(ms);
}
int
ftruncate(int f, soffset sz)
{
USED(f); USED(sz);
return -1;
}
char *
getcwd(char *buf, usize len)
{
USED(buf); USED(len);
return nil;
}
int
chdir(const char *path)
{
USED(path);
return -1;
}
int
access(const char *path, int amode)
{
USED(path); USED(amode);
return -1;
}
void
sys_init(void){}
char os_version[10];
static const u8int boot[] = {
#include "sl.boot.h"
};
int
main(int argc, char **argv)
{
static SysEnvRec r;
memset(&r, 0, sizeof(r));
SysEnvirons(2, &r);
snprintf(
os_version, sizeof(boot),
"%d.%d.%d",
r.systemVersion>>8,
(r.systemVersion>>4)&0xf,
(r.systemVersion>>0)&0xf
);
slmain(boot, sizeof(boot), argc, argv);
}