From ce3e6358aa47a5bbd36558ae1e5a236032a35082 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 17 Feb 2015 16:36:23 -0800 Subject: [PATCH] FRONTPANEL: Add OS X support to sim_frontpanel, add build requirements to documentation. --- sim_frontpanel.c | 34 +++++++++++++++++++++++++++++++++- sim_frontpanel.h | 9 +++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/sim_frontpanel.c b/sim_frontpanel.c index 69ed909a..72ada812 100644 --- a/sim_frontpanel.c +++ b/sim_frontpanel.c @@ -68,12 +68,44 @@ tp->tv_sec = (long)(now/10000000); tp->tv_nsec = (now%10000000)*100; return 0; } -#else +#else /* NOT _WIN32 */ #include #define msleep(n) usleep(1000*n) #include +#if defined (__APPLE__) +#define HAVE_STRUCT_TIMESPEC 1 /* OSX defined the structure but doesn't tell us */ #endif +/* on HP-UX, CLOCK_REALTIME is enum, not preprocessor define */ +#if !defined(CLOCK_REALTIME) && !defined(__hpux) +#define CLOCK_REALTIME 1 +#define NEED_CLOCK_GETTIME 1 +#if !defined(HAVE_STRUCT_TIMESPEC) +#define HAVE_STRUCT_TIMESPEC 1 +#if !defined(_TIMESPEC_DEFINED) +#define _TIMESPEC_DEFINED +struct timespec { + long tv_sec; + long tv_nsec; +}; +#endif /* _TIMESPEC_DEFINED */ +#endif /* HAVE_STRUCT_TIMESPEC */ +#if defined(NEED_CLOCK_GETTIME) +int clock_gettime(int clk_id, struct timespec *tp) +{ +struct timeval cur; +struct timezone foo; + +gettimeofday (&cur, &foo); +tp->tv_sec = cur.tv_sec; +tp->tv_nsec = cur.tv_usec*1000; +return 0; +} +#endif /* defined(NEED_CLOCK_GETTIME) */ +#endif /* !defined(CLOCK_REALTIME) && !defined(__hpux) */ + +#endif /* NOT _WIN32 */ + typedef struct { char *name; void *addr; diff --git a/sim_frontpanel.h b/sim_frontpanel.h index 04ef6da0..578d09cc 100644 --- a/sim_frontpanel.h +++ b/sim_frontpanel.h @@ -29,6 +29,15 @@ simulator. Facilities provide ways to gather information from and to observe and control the state of a simulator. + Any application which wants to use this API needs to: + 1) include this file in the application code + 2) compile sim_frontpanel.c and sim_sock.c from the top level directory + of the simh source. + 3) link the sim_frontpanel and sim_sock object modules and libpthreads + into the application. + 4) Use a simh simulator built from the same version of simh that the + sim_frontpanel and sim_sock modules came from. + */ #ifndef SIM_FRONTPANEL_H_