Exemple #1
0
static void InitTimes (
    Boolean block,
    unsigned long* howlong,
    wait_times_ptr_t wt)
{
    if (block) {
	X_GETTIMEOFDAY (&wt->cur_time);
	FIXUP_TIMEVAL(wt->cur_time);
	wt->start_time = wt->cur_time;
	if(howlong == NULL) { /* special case for ever */
#ifndef USE_POLL
	    wt->wait_time_ptr = NULL;
#else
	    wt->poll_wait = X_BLOCK;
#endif
	} else { /* block until at most */
	    wt->max_wait_time.tv_sec = *howlong/1000;
	    wt->max_wait_time.tv_usec = (*howlong %1000)*1000;
#ifndef USE_POLL
	    wt->wait_time_ptr = &wt->max_wait_time;
#else
	    wt->poll_wait = *howlong;
#endif
	}
    } else {  /* don't block */
	wt->max_wait_time = zero_time;
#ifndef USE_POLL
	wt->wait_time_ptr = &wt->max_wait_time;
#else
	wt->poll_wait = X_DONT_BLOCK;
#endif
    }
}
Exemple #2
0
XtInputMask XETrapAppPending(XtAppContext app)
{
    TimerEventRec *te_ptr;
#ifndef VMS
    struct timeval cur_time;
#else  /* vms */
    vms_time cur_time;
    long efnMask = 0L;
    int status;
#endif /* vms */
    XtInputMask retmask = XtAppPending(app);        /* Prime XtIMEvent */

    retmask &= ~(XtIMTimer | XtIMAlternateInput);   /* clear timer & input */
    /* Now test for timer */
    te_ptr = app->timerQueue;
    while (te_ptr != NULL)
    {
#ifndef vms
        (void)gettimeofday(&cur_time, NULL);
        FIXUP_TIMEVAL(cur_time);
#else
        sys$gettim(&cur_time);
#endif /* vms */
        if (IS_AT_OR_AFTER(te_ptr->te_timer_value, cur_time))
        {   /* this timer is due to fire */
            retmask |= XtIMTimer;
            break;
        }
        te_ptr = te_ptr->te_next;
    }

    /* Now test for alternate input */
#ifndef vms
    if (app->outstandingQueue != NULL)
    {
        retmask |= XtIMAlternateInput;
    }
#else /* vms */
    if ((app->Input_EF_Mask != 0L) && ((status=SYS$READEF(1,&efnMask)) == 1))
    {   /* we have input configured & retrieved the efn cluster 0 */
        efnMask &= app->Input_EF_Mask;  /* mask out non-input */
        if (efnMask)                    /* any left? */
        {                               /* yes, an alt-input efn is set */
            retmask |= XtIMAlternateInput;
        }
    }
#endif  /* vms */
    return(retmask);
}
Exemple #3
0
static void AdjustHowLong (
	unsigned long *howlong,
	struct timeval *start_time)
{
	struct timeval new_time, time_spent, lstart_time;

	lstart_time = *start_time;
	X_GETTIMEOFDAY (&new_time);
	FIXUP_TIMEVAL(new_time);
	TIMEDELTA(time_spent, new_time, lstart_time);
	if(*howlong <= (unsigned long)(time_spent.tv_sec*1000+time_spent.tv_usec/1000))
	    *howlong = (unsigned long)0;  /* Timed out */
	else
	    *howlong -= (time_spent.tv_sec*1000+time_spent.tv_usec/1000);
}