diff --git a/stix/lib/exec.c b/stix/lib/exec.c index 2be9714..f9a7fff 100644 --- a/stix/lib/exec.c +++ b/stix/lib/exec.c @@ -31,6 +31,10 @@ # include #elif defined(__MSDOS__) # include +#elif defined(macintosh) +# include +# include +# include #else /* TODO: remove this header after having changed clock_gettime() to a * platform independent function */ @@ -209,6 +213,14 @@ static STIX_INLINE void vm_gettime (stix_t* stix, stix_ntime_t* now) #else # error UNSUPPORTED CLOCKS_PER_SEC #endif +#elif defined(macintosh) + UnsignedWide tick; + stix_uint64_t tick64; + + Microseconds (&tick); + + tick64 = *(stix_uint64_t*)&tick; + STIX_INITNTIME (now, STIX_USEC_TO_SEC(tick64), STIX_USEC_TO_NSEC(tick64)); #elif defined(HAVE_CLOCK_GETTIME) struct timespec ts; @@ -242,6 +254,10 @@ static STIX_INLINE void vm_sleep (stix_t* stix, const stix_ntime_t* dur) Sleep (STIX_SECNSEC_TO_MSEC(dur->sec,dur->nsec)); } +#elif defined(macintosh) + + /* TODO: ... */ + #elif defined(__MSDOS__) && defined(_INTELC32_) clock_t c; diff --git a/stix/lib/gc.c b/stix/lib/gc.c index 2b4dbeb..898f700 100644 --- a/stix/lib/gc.c +++ b/stix/lib/gc.c @@ -341,12 +341,12 @@ printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n", for (i = 0; i < stix->sem_list_count; i++) { - stix->sem_list[i] = (stix_oop_semaphore_t)stix_moveoop (stix, stix->sem_list[i]); + stix->sem_list[i] = (stix_oop_semaphore_t)stix_moveoop (stix, (stix_oop_t)stix->sem_list[i]); } for (i = 0; i < stix->sem_heap_count; i++) { - stix->sem_heap[i] = (stix_oop_semaphore_t)stix_moveoop (stix, stix->sem_heap[i]); + stix->sem_heap[i] = (stix_oop_semaphore_t)stix_moveoop (stix, (stix_oop_t)stix->sem_heap[i]); } for (i = 0; i < stix->tmp_count; i++) diff --git a/stix/lib/main.c b/stix/lib/main.c index b23b765..100db71 100644 --- a/stix/lib/main.c +++ b/stix/lib/main.c @@ -47,7 +47,7 @@ #elif defined(__MSDOS__) # include #elif defined(macintosh) - /* nothing to include */ +# include #else # include # include @@ -404,6 +404,16 @@ static void timer_intr_handler (void) _chain_intr(prev_timer_intr_handler); } +#elif defined(macintosh) + +static TMTask g_tmtask; + +static pascal void timer_intr_handler (TMTask* task) +{ + if (g_stix) stix_switchprocess (g_stix); +} + + #else static void arrange_process_switching (int sig) { @@ -418,6 +428,18 @@ static void setup_tick (void) prev_timer_intr_handler = _dos_getvect (0x1C); _dos_setvect (0x1C, timer_intr_handler); +#elif defined(macintosh) + + long delay = 50; + + memset (&g_tmtask, 0, STIX_SIZEOF(g_tmtask)); + g_tmtask.tmAddr = NewTimerProc (timer_intr_handler); + InsXTime ((QElem*)&g_tmtask); + + /* if delay is positive, it's in milliseconds. + * if it's negative, it's in negated microsecond */ + PrimeTime ((QElem*)&g_tmtask, delay); + #elif defined(HAVE_SETITIMER) && defined(SIGVTALRM) && defined(ITIMER_VIRTUAL) struct itimerval itv; struct sigaction act; @@ -444,6 +466,10 @@ static void cancel_tick (void) _dos_setvect (0x1C, prev_timer_intr_handler); +#elif defined(macintosh) + RmvTime ((QElem*)&g_tmtask); + /*DisposeTimerProc (g_tmtask.tmAddr);*/ + #elif defined(HAVE_SETITIMER) && defined(SIGVTALRM) && defined(ITIMER_VIRTUAL) struct itimerval itv; struct sigaction act; @@ -454,7 +480,6 @@ static void cancel_tick (void) itv.it_value.tv_usec = 0; setitimer (ITIMER_VIRTUAL, &itv, STIX_NULL); - sigemptyset (&act.sa_mask); act.sa_handler = SIG_DFL; act.sa_flags = 0;