/* PUBLIC HTVMS_cancel_timer() ** Cancel a specific or all timers ** ON ENTRY: ** n timer number (0 to cancel all timers) ** ** ** ON EXIT: ** */ PUBLIC void HTVMS_cancel_timer ARGS1( CONST int, n) { long Result; Result = SYS$CANTIM(n, 0); }
static void waitForSomething(void) { #if defined(__vms) && ( __VMS_VER < 70000000 ) static struct timeval6 zerotime = {0}; unsigned int timer_efn; #define timer_id 'glut' /* random :-) number */ unsigned int wait_mask; #else static struct timeval zerotime = {0, 0}; #if !defined(_WIN32) fd_set fds; #endif #endif #ifdef OLD_VMS struct timeval6 now, timeout, waittime; #else struct timeval now, timeout, waittime; #endif #if !defined(_WIN32) int rc; #endif /* Flush X protocol since XPending does not do this implicitly. */ XFlush(__glutDisplay); if (XPending(__glutDisplay)) { /* It is possible (but quite rare) that XFlush may have needed to wait for a writable X connection file descriptor, and in the process, may have had to read off X protocol from the file descriptor. If XPending is true, this case occured and we should avoid waiting in select since X protocol buffered within Xlib is due to be processed and potentially no more X protocol is on the file descriptor, so we would risk waiting improperly in select. */ goto immediatelyHandleXinput; } #if defined(__vms) && ( __VMS_VER < 70000000 ) timeout = __glutTimerList->timeout; GETTIMEOFDAY(&now); wait_mask = 1 << (__glutConnectionFD & 31); if (IS_AFTER(now, timeout)) { /* We need an event flag for the timer. */ /* XXX The `right' way to do this is to use LIB$GET_EF, but since it needs to be in the same cluster as the EFN for the display, we will have hack it. */ timer_efn = __glutConnectionFD - 1; if ((timer_efn / 32) != (__glutConnectionFD / 32)) { timer_efn = __glutConnectionFD + 1; } rc = SYS$CLREF(timer_efn); rc = SYS$SETIMR(timer_efn, &timeout, NULL, timer_id, 0); wait_mask |= 1 << (timer_efn & 31); } else { timer_efn = 0; } rc = SYS$WFLOR(__glutConnectionFD, wait_mask); if (timer_efn != 0 && SYS$CLREF(timer_efn) == SS$_WASCLR) { rc = SYS$CANTIM(timer_id, PSL$C_USER); } /* XXX There does not seem to be checking of "rc" in the code above. Can any of the SYS$ routines above fail? */ #else /* not vms6.2 or lower */ #if !defined(_WIN32) FD_ZERO(&fds); FD_SET(__glutConnectionFD, &fds); #endif timeout = __glutTimerList->timeout; GETTIMEOFDAY(&now); if (IS_AFTER(now, timeout)) { TIMEDELTA(waittime, timeout, now); } else { waittime = zerotime; } #if !defined(_WIN32) rc = select(__glutConnectionFD + 1, &fds, NULL, NULL, &waittime); if (rc < 0 && errno != EINTR) __glutFatalError("select error."); #else MsgWaitForMultipleObjects(0, NULL, FALSE, waittime.tv_sec*1000 + waittime.tv_usec/1000, QS_ALLINPUT); #endif #endif /* not vms6.2 or lower */ /* Without considering the cause of select unblocking, check for pending X events and handle any timeouts (by calling processEventsAndTimeouts). We always look for X events even if select returned with 0 (indicating a timeout); otherwise we risk starving X event processing by continous timeouts. */ if (XPending(__glutDisplay)) { immediatelyHandleXinput: processEventsAndTimeouts(); } else { if (__glutTimerList) handleTimeouts(); } }