#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
__attribute__((import_module("env"), import_name("__rquickjs_host_now_us")))
extern double __rquickjs_host_now_us(void);
int gettimeofday(struct timeval *restrict tv, void *restrict tz) {
(void)tz;
long long us = (long long)__rquickjs_host_now_us();
tv->tv_sec = (time_t)(us / 1000000);
tv->tv_usec = (suseconds_t)(us % 1000000);
return 0;
}
int clock_gettime(clockid_t clock, struct timespec *ts) {
(void)clock;
long long us = (long long)__rquickjs_host_now_us();
ts->tv_sec = (time_t)(us / 1000000);
ts->tv_nsec = (long)((us % 1000000) * 1000);
return 0;
}
struct tm *localtime_r(const time_t *restrict t, struct tm *restrict tm) {
(void)t;
memset(tm, 0, sizeof(*tm));
return tm;
}
_Noreturn void abort(void) { __builtin_trap(); }
_Noreturn void __assert_fail(const char *expr, const char *file, int line,
const char *func) {
(void)expr;
(void)file;
(void)line;
(void)func;
__builtin_trap();
}
int fprintf(FILE *restrict f, const char *restrict fmt, ...) {
(void)f;
(void)fmt;
return 0;
}
int fputc(int c, FILE *f) {
(void)f;
return c;
}
int putchar(int c) { return c; }
int fputs(const char *restrict s, FILE *restrict f) {
(void)s;
(void)f;
return 0;
}
int fflush(FILE *f) {
(void)f;
return 0;
}
size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) {
(void)f;
(void)buf;
return len;
}
size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) {
(void)f;
(void)buf;
return len;
}
off_t __stdio_seek(FILE *f, off_t off, int whence) {
(void)f;
(void)off;
(void)whence;
return -1;
}
int __stdio_close(FILE *f) {
(void)f;
return 0;
}
int __isatty(int fd) {
(void)fd;
return 0;
}