This commit is contained in:
folkert van heusden 2022-11-09 21:25:55 +01:00
parent f59ae65e5e
commit 4ccc53f5f2
3 changed files with 10 additions and 6 deletions

View file

@ -2,6 +2,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "error.h"
@ -71,7 +72,7 @@ void dolog(const log_level_t ll, const char *fmt, ...)
uint64_t now = get_us();
time_t t_now = now / 1000000;
struct tm tm { 0 };
tm tm { 0 };
if (!localtime_r(&t_now, &tm))
error_exit(true, "localtime_r failed");

View file

@ -44,6 +44,7 @@ void help()
printf("-h this help\n");
printf("-T t.bin load file as a binary tape file (like simh \"load\" command)\n");
printf("-R d.rk load file as a RK05 disk device\n");
printf("-r d.rk load file as a RL02 disk device\n");
printf("-p 123 set CPU start pointer to decimal(!) value\n");
printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n");
printf("-n ncurses UI\n");

View file

@ -4,10 +4,12 @@
#include <Arduino.h>
#endif
#include <errno.h>
#include <pthread.h>
#include <stdarg.h>
#include <stdint.h>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>
#include <sys/time.h>
@ -41,7 +43,7 @@ unsigned long get_ms()
#if defined(ESP32)
return millis();
#else
struct timeval tv;
timeval tv;
// TODO replace gettimeofday by clock_gettime
gettimeofday(&tv, NULL);
@ -55,7 +57,7 @@ uint64_t get_us()
#if defined(ESP32)
return micros();
#else
struct timeval tv;
timeval tv;
// TODO replace gettimeofday by clock_gettime
gettimeofday(&tv, NULL);
@ -87,20 +89,20 @@ void myusleep(uint64_t us)
}
}
#else
struct timespec req;
timespec req;
req.tv_sec = us / 1000000l;
req.tv_nsec = (us % 1000000l) * 1000l;
for(;;) {
struct timespec rem { 0, 0 };
timespec rem { 0, 0 };
int rc = nanosleep(&req, &rem);
if (rc == 0 || (rc == -1 && errno != EINTR))
break;
memcpy(&req, &rem, sizeof(struct timespec));
memcpy(&req, &rem, sizeof(timespec));
}
#endif
}