added some support routines for classic mac os
This commit is contained in:
		@ -31,6 +31,10 @@
 | 
			
		||||
#	include <windows.h>
 | 
			
		||||
#elif defined(__MSDOS__)
 | 
			
		||||
#	include <time.h>
 | 
			
		||||
#elif defined(macintosh)
 | 
			
		||||
#	include <Types.h>
 | 
			
		||||
#	include <OSUtils.h>
 | 
			
		||||
#	include <Timer.h>
 | 
			
		||||
#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;
 | 
			
		||||
 | 
			
		||||
@ -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++)
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,7 @@
 | 
			
		||||
#elif defined(__MSDOS__)
 | 
			
		||||
#	include <dos.h>
 | 
			
		||||
#elif defined(macintosh)
 | 
			
		||||
	/* nothing to include */
 | 
			
		||||
#	include <Timer.h>
 | 
			
		||||
#else
 | 
			
		||||
#	include <unistd.h>
 | 
			
		||||
#	include <ltdl.h>
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user