/* * plc_LoopWait() * * Description: * Returns FALSE if a slip is detected. */ pwr_tBoolean plc_LoopWait ( int *WaitResult, /* Set to 1 when Event */ pwr_tVaxTime *DeltaTime, pwr_tVaxTime *NextTime, unsigned long Event ) { pwr_tStatus sts; pwr_tVaxTime NextLoop, UpTime, DiffTime; pwr_tBoolean Result; sts = lib$add_times(NextTime, DeltaTime, &NextLoop); *NextTime = NextLoop; ker$get_uptime(&sts, &UpTime); sts = lib$sub_times(NextTime, &UpTime, &DiffTime); if (sts == LIB$_NEGTIM) Result = FALSE; /* Slip */ else if (NextTime->high == UpTime.high && NextTime->low == UpTime.low) Result = TRUE; /* Equal Times */ else { if (Event) ker$wait_any(&sts, WaitResult, &DiffTime, Event); else ker$wait_any(&sts, WaitResult, &DiffTime); Result = TRUE; } return Result; }
/* Wait for either Timer, Alternate Input, or an X Event to arrive */ int XETrapWaitForSomething(XtAppContext app) { #ifndef vms return(_XtWaitForSomething(app, FALSE, FALSE, FALSE, FALSE, TRUE #ifdef XTHREADS , FALSE #endif /* XTHREADS */ , 0L)); #else /* vms */ #define IS_AFTER(t1,t2) (((t2).high > (t1).high) \ ||(((t2).high == (t1).high)&& ((t2).low > (t1).low))) long retval = 0L; TimerEventRec *te_ptr; vms_time cur_time,result_time; int status = 0; long quotient, remainder = 0; int d; if (app->timerQueue!= NULL) { /* check timeout queue */ cur_time.low = cur_time.high = result_time.low = result_time.high = 0; te_ptr = app->timerQueue; sys$gettim(&cur_time); if ((IS_AFTER(app->timerQueue->te_timer_value, cur_time)) && (app->timerQueue->te_proc != 0)) { /* it's fired! return! */ return(0); } /* Jump through hoops to get the time specified in the queue into * milliseconds */ status = lib$sub_times (&(te_ptr->te_timer_value.low), &cur_time, &result_time); /* * See if this timer has expired. A timer is considered expired * if it's value in the past (the NEGTIM case) or if there is * less than one integral milli second before it would go off. */ if (status == LIB$_NEGTIM || (result_time.high == -1 && result_time.low > -10000)) { /* We've got a timer and it's ready to fire! */ return(0); } else if ((status & 1) == 1) { lib$ediv (&(10000), &result_time, "ient, &remainder); quotient *= -1; /* flip the sign bit */ return(XMultiplexInput(app->count, &(app->list[0L]), app->Input_EF_Mask, quotient, 0L, &retval)); } else { status = -1; } } return((status == -1 ? -1 : XMultiplexInput(app->count, &(app->list[0L]), app->Input_EF_Mask, 0L, 0L, &retval))); #endif /* vms */ }