added some support routines for classic mac os

This commit is contained in:
hyunghwan.chung 2016-05-19 03:49:23 +00:00
parent 50776d945f
commit c39aa957ad
3 changed files with 45 additions and 4 deletions

View File

@ -31,6 +31,10 @@
# include <windows.h> # include <windows.h>
#elif defined(__MSDOS__) #elif defined(__MSDOS__)
# include <time.h> # include <time.h>
#elif defined(macintosh)
# include <Types.h>
# include <OSUtils.h>
# include <Timer.h>
#else #else
/* TODO: remove this header after having changed clock_gettime() to a /* TODO: remove this header after having changed clock_gettime() to a
* platform independent function */ * platform independent function */
@ -209,6 +213,14 @@ static STIX_INLINE void vm_gettime (stix_t* stix, stix_ntime_t* now)
#else #else
# error UNSUPPORTED CLOCKS_PER_SEC # error UNSUPPORTED CLOCKS_PER_SEC
#endif #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) #elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts; 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)); Sleep (STIX_SECNSEC_TO_MSEC(dur->sec,dur->nsec));
} }
#elif defined(macintosh)
/* TODO: ... */
#elif defined(__MSDOS__) && defined(_INTELC32_) #elif defined(__MSDOS__) && defined(_INTELC32_)
clock_t c; clock_t c;

View File

@ -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++) 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++) 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++) for (i = 0; i < stix->tmp_count; i++)

View File

@ -47,7 +47,7 @@
#elif defined(__MSDOS__) #elif defined(__MSDOS__)
# include <dos.h> # include <dos.h>
#elif defined(macintosh) #elif defined(macintosh)
/* nothing to include */ # include <Timer.h>
#else #else
# include <unistd.h> # include <unistd.h>
# include <ltdl.h> # include <ltdl.h>
@ -404,6 +404,16 @@ static void timer_intr_handler (void)
_chain_intr(prev_timer_intr_handler); _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 #else
static void arrange_process_switching (int sig) static void arrange_process_switching (int sig)
{ {
@ -418,6 +428,18 @@ static void setup_tick (void)
prev_timer_intr_handler = _dos_getvect (0x1C); prev_timer_intr_handler = _dos_getvect (0x1C);
_dos_setvect (0x1C, timer_intr_handler); _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) #elif defined(HAVE_SETITIMER) && defined(SIGVTALRM) && defined(ITIMER_VIRTUAL)
struct itimerval itv; struct itimerval itv;
struct sigaction act; struct sigaction act;
@ -444,6 +466,10 @@ static void cancel_tick (void)
_dos_setvect (0x1C, prev_timer_intr_handler); _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) #elif defined(HAVE_SETITIMER) && defined(SIGVTALRM) && defined(ITIMER_VIRTUAL)
struct itimerval itv; struct itimerval itv;
struct sigaction act; struct sigaction act;
@ -454,7 +480,6 @@ static void cancel_tick (void)
itv.it_value.tv_usec = 0; itv.it_value.tv_usec = 0;
setitimer (ITIMER_VIRTUAL, &itv, STIX_NULL); setitimer (ITIMER_VIRTUAL, &itv, STIX_NULL);
sigemptyset (&act.sa_mask); sigemptyset (&act.sa_mask);
act.sa_handler = SIG_DFL; act.sa_handler = SIG_DFL;
act.sa_flags = 0; act.sa_flags = 0;