removed some redundant code

This commit is contained in:
hyunghwan.chung 2018-11-19 16:00:55 +00:00
parent 44c72e07e6
commit 2cef223f4c

View File

@ -2770,37 +2770,28 @@ static void __interrupt dos_timer_intr_handler (void)
_chain_intr (dos_prev_timer_intr_handler);
}
static void moo_start_ticker (void)
static MOO_INLINE void start_ticker (void)
{
if (++ticker_started == 1)
{
dos_prev_timer_intr_handler = _dos_getvect(0x1C);
_dos_setvect (0x1C, dos_timer_intr_handler);
}
}
static void moo_stop_ticker (void)
static MOO_INLINE void moo_stop_ticker (void)
{
if (ticker_started > 0 && --ticker_started == 0)
{
_dos_setvect (0x1C, dos_prev_timer_intr_handler);
}
}
#elif defined(_WIN32)
static HANDLE win_tick_timer = MOO_NULL; /*INVALID_HANDLE_VALUE;*/
static moo_uint32_t ticker_started = 0;
static VOID CALLBACK arrange_process_switching (LPVOID arg, DWORD timeLow, DWORD timeHigh)
{
swproc_all_moos ();
}
static void moo_start_ticker (void)
static MOO_INLINE void start_ticker (void)
{
if (++ticker_started == 1)
{
LARGE_INTEGER li;
win_tick_timer = CreateWaitableTimer(MOO_NULL, TRUE, MOO_NULL);
if (win_tick_timer)
@ -2808,20 +2799,16 @@ static void moo_start_ticker (void)
li.QuadPart = -MOO_SECNSEC_TO_NSEC(0, 20000); /* 20000 microseconds. 0.02 seconds */
SetWaitableTimer (win_tick_timer, &li, 0, arrange_process_switching, MOO_NULL, FALSE);
}
}
}
static void moo_stop_ticker (void)
static MOO_INLINE void stop_ticker (void)
{
if (ticker_started > 0 && --ticker_started == 0)
{
if (win_tick_timer)
{
CancelWaitableTimer (win_tick_timer);
CloseHandle (win_tick_timer);
win_tick_timer = MOO_NULL;
}
}
}
#elif defined(__OS2__)
@ -2829,7 +2816,6 @@ static TID os2_tick_tid;
static HEV os2_tick_sem;
static HTIMER os2_tick_timer;
static int os2_tick_done = 0;
static moo_uint32_t ticker_started = 0;
static void EXPENTRY os2_wait_for_timer_event (ULONG x)
{
@ -2862,22 +2848,16 @@ static void EXPENTRY os2_wait_for_timer_event (ULONG x)
DosExit (EXIT_THREAD, 0);
}
static void moo_start_ticker (void)
static MOO_INLINE void start_ticker (void)
{
if (++ticker_started == 1)
{
/* TODO: Error check */
DosCreateThread (&os2_tick_tid, os2_wait_for_timer_event, 0, 0, 4096);
}
}
static void moo_stop_ticker (void)
static MOO_INLINE void stop_ticker (void)
{
if (ticker_started > 0 && --ticker_started == 0)
{
if (os2_tick_sem) DosPostEventSem (os2_tick_sem);
os2_tick_done = 1;
}
}
#elif defined(macintosh)
@ -2894,7 +2874,7 @@ static pascal void timer_intr_handler (TMTask* task)
PrimeTime ((QElem*)&mac_tmtask, TMTASK_DELAY);
}
static void moo_start_ticker (void)
static MOO_INLINE void start_ticker (void)
{
GetCurrentProcess (&mac_psn);
memset (&mac_tmtask, 0, MOO_SIZEOF(mac_tmtask));
@ -2903,7 +2883,7 @@ static void moo_start_ticker (void)
PrimeTime ((QElem*)&mac_tmtask, TMTASK_DELAY);
}
static void moo_stop_ticker (void)
static MOO_INLINE void stop_ticker (void)
{
RmvTime ((QElem*)&mac_tmtask);
/*DisposeTimerProc (mac_tmtask.tmAddr);*/
@ -2916,12 +2896,9 @@ static void arrange_process_switching (int sig)
swproc_all_moos ();
}
static moo_uint32_t ticker_started = 0;
void moo_start_ticker (void)
static MOO_INLINE void start_ticker (void)
{
if (++ticker_started == 1)
{
if (set_signal_handler(SIGVTALRM, arrange_process_switching, SA_RESTART) >= 0)
{
struct itimerval itv;
@ -2933,13 +2910,10 @@ void moo_start_ticker (void)
itv.it_value.tv_usec = MOO_ITIMER_TICK;
setitimer (ITIMER_VIRTUAL, &itv, MOO_NULL);
}
}
}
void moo_stop_ticker (void)
static MOO_INLINE void stop_ticker (void)
{
if (ticker_started > 0 && --ticker_started == 0)
{
/* ignore the signal fired by the activated timer.
* unsetting the signal may cause the program to terminate(default action) */
if (set_signal_handler(SIGVTALRM, SIG_IGN, 0) >= 0)
@ -2951,7 +2925,6 @@ void moo_stop_ticker (void)
itv.it_value.tv_usec = 0;
setitimer (ITIMER_VIRTUAL, &itv, MOO_NULL);
}
}
}
#else
@ -3410,3 +3383,23 @@ void moo_rcvtickstd (moo_t* moo, int v)
xtn_t* xtn = GET_XTN(moo);
xtn->rcv_tick = v;
}
/* ========================================================================= */
static moo_uint32_t ticker_started = 0;
void moo_start_ticker (void)
{
if (++ticker_started == 1)
{
start_ticker ();
}
}
void moo_stop_ticker (void)
{
if (ticker_started > 0 && --ticker_started == 0)
{
stop_ticker ();
}
}