Zungmann's fixes to compile simulator on Mac OS X, part 1.
Compiling for Mac OS X needs some customizations noticed by zungmann in the reprap forum: http://forums.reprap.org/read.php?147,33082,279050#msg-279050
This commit is contained in:
parent
3fcd6b3c59
commit
5cd6cf50d8
|
|
@ -18,7 +18,7 @@ static int32_t values[MAX_PINS]; ///< Pin and value states
|
||||||
static int pin_count; ///< Number of pins we emit
|
static int pin_count; ///< Number of pins we emit
|
||||||
static void emit_log_data(void);
|
static void emit_log_data(void);
|
||||||
|
|
||||||
static void recorder_close(int code, void*x ) {
|
static void recorder_close(void) {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
// force last line to emit
|
// force last line to emit
|
||||||
emit_log_data();
|
emit_log_data();
|
||||||
|
|
@ -42,7 +42,7 @@ void recorder_init(const char* filename) {
|
||||||
fprintf(file, "#\n");
|
fprintf(file, "#\n");
|
||||||
|
|
||||||
fflush(file);
|
fflush(file);
|
||||||
on_exit(recorder_close, NULL);
|
atexit((void*)recorder_close);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_trace_var(const char* name, int pin) {
|
void add_trace_var(const char* name, int pin) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,13 @@
|
||||||
#include "dda_queue.h"
|
#include "dda_queue.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "simulator.h"
|
#include "simulator.h"
|
||||||
#include <time.h>
|
#ifdef __MACH__
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
#define CLOCK_MONOTONIC 0
|
||||||
|
#else
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h> // printf
|
#include <stdio.h> // printf
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
|
|
||||||
|
|
@ -28,6 +34,21 @@ static volatile uint8_t timer_reason; // Who scheduled this timer
|
||||||
static uint64_t ticks;
|
static uint64_t ticks;
|
||||||
static uint32_t warpTarget;
|
static uint32_t warpTarget;
|
||||||
|
|
||||||
|
#ifdef __MACH__
|
||||||
|
int clock_gettime(int clk_id, struct timespec *t) {
|
||||||
|
mach_timebase_info_data_t timebase;
|
||||||
|
mach_timebase_info(&timebase);
|
||||||
|
uint64_t time;
|
||||||
|
|
||||||
|
time = mach_absolute_time();
|
||||||
|
double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);
|
||||||
|
double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);
|
||||||
|
t->tv_sec = seconds;
|
||||||
|
t->tv_nsec = nseconds;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint64_t now_ns(void) {
|
static uint64_t now_ns(void) {
|
||||||
struct timespec tv;
|
struct timespec tv;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue