/* Close up the TTY and restore. */ void diag_tty_close(struct diag_l0_device *dl0d) { struct unix_tty_int *uti; if (!dl0d) return; uti = (struct unix_tty_int *)dl0d->tty_int; if (!uti) return; if (uti->name) { free(uti->name); } #if defined(_POSIX_TIMERS) && (SEL_TIMEOUT==S_POSIX || SEL_TIMEOUT==S_AUTO) timer_delete(uti->timerid); #endif if (uti->fd != DL0D_INVALIDHANDLE) { #if defined(__linux__) if (uti->tioc_works) (void)ioctl(uti->fd, TIOCSSERIAL, &uti->ss_orig); #endif #ifdef USE_TERMIOS2 (void)ioctl(uti->fd, TCSETS2, &uti->st2_orig); #else (void)tcsetattr(uti->fd, TCSADRAIN, &uti->st_orig); #endif (void)ioctl(uti->fd, TIOCMSET, &uti->modemflags); (void)close(uti->fd); } free(uti); dl0d->tty_int = NULL; return; }
/* * Handle a message that will cause us to stop. */ static void actionTimerServerStop (void) { UInt32 x = 0; TimerEntry * pEntry; /* Return used timers to the free list */ freeAllTimers (); pthread_mutex_lock (&lockLinkedLists); pEntry = pgFreeTimerListHead; /* Assign this here in case it has been changed by whoever held the lock */ /* Free the free list */ for (x = 0; (pEntry != PNULL) && (x < MAX_NUM_TIMERS); x++) { TimerEntry * pNextEntry = pEntry->pNextEntry; free (pEntry); pEntry = pNextEntry; } pgFreeTimerListHead = PNULL; if (timer_delete (gTimerId) != 0) { ASSERT_ALWAYS_STRING ("actionTimerServerStop: failed timer_delete()."); } pthread_mutex_unlock (&lockLinkedLists); /* Destroy the mutex */ pthread_mutex_destroy (&lockLinkedLists); }
/******************************************************************************* ** ** Function lpm_cleanup ** ** Description Clean up ** ** Returns None ** *******************************************************************************/ void lpm_cleanup(void) { if (bt_lpm_cb.timer_created == TRUE) { timer_delete(bt_lpm_cb.timer_id); } }
//--------------------------------------------------------------------------- // Function: EplTimerHighReskDelInstance() // // Description: shuts down the high resolution timer module. // // Parameters: void // // Return: tEplKernel = error code //--------------------------------------------------------------------------- tEplKernel PUBLIC EplTimerHighReskDelInstance(void) { tEplTimerHighReskTimerInfo* pTimerInfo; tEplKernel Ret; UINT uiIndex; Ret = kEplSuccessful; for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++) { pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex]; timer_delete(pTimerInfo->m_timer); pTimerInfo->m_EventArg.m_TimerHdl = 0; pTimerInfo->m_pfnCallback = NULL; } /* send exit signal to thread */ pthread_cancel(EplTimerHighReskInstance_l.m_thread); /* wait until thread terminates */ EPL_DBGLVL_TIMERH_TRACE1("%s() Waiting for thread to exit...\n", __func__); pthread_join(EplTimerHighReskInstance_l.m_thread, NULL); EPL_DBGLVL_TIMERH_TRACE1("%s() Thread exited!\n", __func__); return Ret; }
RequestTimer::~RequestTimer() { #ifndef __APPLE__ if (m_hasTimer) { timer_delete(m_timer_id); } #endif }
/******************************************************************************* ** ** Function lpm_vnd_cback ** ** Description Callback of vendor specific result for lpm enable/disable ** rquest ** ** Returns None ** *******************************************************************************/ void lpm_vnd_cback(uint8_t vnd_result) { if (vnd_result == 0) { /* Status == Success */ bt_lpm_cb.state = (bt_lpm_cb.state == LPM_ENABLING) ? \ LPM_ENABLED : LPM_DISABLED; } else { bt_lpm_cb.state = (bt_lpm_cb.state == LPM_ENABLING) ? \ LPM_DISABLED : LPM_ENABLED; } if (bt_hc_cbacks) { if (bt_lpm_cb.state == LPM_ENABLED) bt_hc_cbacks->lpm_cb(BT_HC_LPM_ENABLED); else bt_hc_cbacks->lpm_cb(BT_HC_LPM_DISABLED); } if (bt_lpm_cb.state == LPM_DISABLED) { if (bt_lpm_cb.timer_created == TRUE) { timer_delete(bt_lpm_cb.timer_id); } memset(&bt_lpm_cb, 0, sizeof(bt_lpm_cb_t)); } }
/***************************************************************************** * Function * mtk_nfc_sys_timer_delete * DESCRIPTION * Delete a timer * PARAMETERS * timer_slot [IN] a valid timer slot * RETURNS * NONE *****************************************************************************/ void mtk_nfc_sys_timer_delete ( MTK_NFC_TIMER_E timer_slot ) { if (timer_slot >= MTK_NFC_TIMER_MAX_NUM) { #ifdef DEBUG_LOG ALOGD("[TIMER]exceed max num of nfc timer,%d\r\n", timer_slot); #endif return; } if (nfc_timer_table[timer_slot].is_used == 0) { #ifdef DEBUG_LOG ALOGD("[TIMER]timer_slot(%d) already be deleted\r\n", timer_slot); #endif return; } timer_delete(nfc_timer_table[timer_slot].handle); nfc_timer_table[timer_slot].handle = 0; nfc_timer_table[timer_slot].timer_expiry_callback = NULL; nfc_timer_table[timer_slot].timer_expiry_context = NULL; nfc_timer_table[timer_slot].is_used = 0; // clear used flag #ifdef DEBUG_LOG ALOGD("[TIMER]timer_slot(%d) delete\r\n", timer_slot); #endif }
void timer_delete_all(void) { static int i; for(i = 0; i < TIMER_NUM_SLOTS; i++) { timer_delete(i); } }
int timer_remove(long timer_id) { int rc = 0; struct timer_elm_s *timer_p; TMR_DEBUG("Removing timer 0x%lx\n", timer_id); pthread_mutex_lock(&timer_desc.timer_list_mutex); TIMER_SEARCH(timer_p, timer, ((timer_t)timer_id), &timer_desc.timer_queue); /* We didn't find the timer in list */ if (timer_p == NULL) { pthread_mutex_unlock(&timer_desc.timer_list_mutex); TMR_ERROR("Didn't find timer 0x%lx in list\n", timer_id); return -1; } STAILQ_REMOVE(&timer_desc.timer_queue, timer_p, timer_elm_s, entries); pthread_mutex_unlock(&timer_desc.timer_list_mutex); if (timer_delete(timer_p->timer) < 0) { TMR_ERROR("Failed to delete timer 0x%lx\n", (long)timer_p->timer); rc = -1; } free(timer_p); timer_p = NULL; return rc; }
~imp() { #if defined(_WINDOWS) || defined(_CYGWIN) DeleteTimerQueueTimer(NULL, m_timer, INVALID_HANDLE_VALUE); #elif defined(__APPLE__) && defined(__MACH__) // Mac OS X // If the waiting-thread is not up and waiting yet, // we can make sure that it finishes quickly by // setting the end-time to zero. m_end_time.tv_sec = 0; m_end_time.tv_nsec = 0; // Otherwise it's already up and waiting, and // we can send a signal on m_condition_var: pthread_mutex_lock(&m_mutex); pthread_cond_signal(&m_condition_var); pthread_mutex_unlock(&m_mutex); if (pthread_join(m_thread_id, NULL) != 0) throw default_exception("failed to join thread"); if (pthread_mutex_destroy(&m_mutex) != 0) throw default_exception("failed to destroy pthread mutex"); if (pthread_cond_destroy(&m_condition_var) != 0) throw default_exception("failed to destroy pthread condition variable"); if (pthread_attr_destroy(&m_attributes) != 0) throw default_exception("failed to destroy pthread attributes object"); #elif defined(_LINUX_) || defined(_FREEBSD_) // Linux & FreeBSD timer_delete(m_timerid); #else // Other Platforms #endif }
RequestInjectionData::~RequestInjectionData() { #ifndef __APPLE__ if (m_hasTimer) { timer_delete(m_timer_id); } #endif }
/****************************************************************************** ** Function: OS_TimerDelete ** ** Purpose: ** ** Arguments: ** (none) ** ** Return: ** (none) */ int32 OS_TimerDelete(uint32 timer_id) { int status; /* ** Check to see if the timer_id given is valid */ if (timer_id >= OS_MAX_TIMERS) { return OS_ERR_INVALID_ID; } semTake(OS_timer_table_sem,WAIT_FOREVER); if (OS_timer_table[timer_id].free == TRUE) { semGive(OS_timer_table_sem); return OS_ERR_INVALID_ID; } OS_timer_table[timer_id].free = TRUE; semGive(OS_timer_table_sem); /* ** Delete the timer */ status = timer_delete((timer_t)(OS_timer_table[timer_id].host_timerid)); if (status < 0) { return ( OS_TIMER_ERR_INTERNAL); } return OS_SUCCESS; }
int main(int ac, char **av) { int lc; /* loop counter */ char *msg; /* message returned from parse_opts */ timer_t timer_id; /* parse standard options */ if ((msg = parse_opts (ac, av, (option_t *) NULL, NULL)) != (char *) NULL) { tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); } /* perform global setup for test */ setup(); /* check looping state if -i option given */ for (lc = 0; TEST_LOOPING(lc); lc++) { /* reset Tst_count in case we are looping. */ Tst_count = 0; /* Create a Posix timer */ if (timer_create(CLOCK_REALTIME, NULL, &timer_id) < 0) { /* If timer_create system call is not implemented * in the running kernel, this will fail with ENOSYS */ Tst_count = TST_TOTAL; perror("timer_create"); tst_brkm(TBROK, cleanup, "timer_delete can't be" " tested because timer_create failed"); } TEST(timer_delete(timer_id)); if (TEST_RETURN == -1) { /* If timer_delete system call is not implemented * in the running kernel, test will fail with ENOSYS */ if (TEST_ERRNO == ENOSYS) { Tst_count = TST_TOTAL; perror("timer_delete"); tst_brkm(TBROK, cleanup, ""); } TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL, "timer_delete(2) Failed and set errno" " to %d", TEST_ERRNO); } else { tst_resm(TPASS, "timer_delete(2) Passed"); } } /* End for TEST_LOOPING */ /* Clean up and exit */ cleanup(); /* NOTREACHED */ return 0; }
void teardown_control() { timer_delete(timer); if(pthread_mutex_destroy(&mutex)){ syslog(LOG_ERR, "Error destroying mutex: %m (%s)%d", __FILE__, __LINE__); } }
void _odp_timer_fini(odp_timer_pool *tp) { if (timer_delete(tp->timerid) != 0) ODP_ABORT("timer_delete() returned error %s\n", strerror(errno)); if(_odp_timer_pool_global == tp) _odp_timer_pool_global = NULL; }
int prime_timers(timer_t *mld, timer_t *pim) { struct itimerspec timer; struct sigevent event; event.sigev_notify = SIGEV_SIGNAL; event.sigev_signo = SIGUSR1; if (timer_create(CLOCK_MONOTONIC, &event, mld)) { logger(LOG_ERR, errno, "timer_create(mld)"); return -EX_OSERR; } timer.it_value.tv_sec = RFC3376_RFC3810_Query_Interval; timer.it_value.tv_nsec = 0; timer.it_interval.tv_sec = RFC3376_RFC3810_Query_Interval; timer.it_interval.tv_nsec = 0; if (timer_settime(*mld, 0, &timer, NULL)) { logger(LOG_ERR, errno, "timer_settime(mld)"); goto mld; } event.sigev_signo = SIGUSR2; if (timer_create(CLOCK_MONOTONIC, &event, pim)) { logger(LOG_ERR, errno, "timer_create(pim)"); goto mld; } timer.it_value.tv_nsec = genrand(RFC4601_Triggered_Hello_Delay * (int) 1e6); timer.it_value.tv_sec = (time_t) timer.it_value.tv_nsec / 1e6; timer.it_value.tv_nsec = timer.it_value.tv_nsec % (int) 1e6; timer.it_interval.tv_sec = RFC4601_Hello_Period; timer.it_interval.tv_nsec = 0; if (timer_settime(*pim, 0, &timer, NULL)) { logger(LOG_ERR, errno, "timer_settime(pim)"); goto pim; } return EX_OK; pim: timer_delete(*pim); mld: timer_delete(*mld); return -EX_OSERR; }
/** * @brief Stop & close the timer * * @return Operation status * @retval 0 OK * @retval <0 error */ static int close_timer(void) { if (timer_delete(timerid) == -1) { printf("Error deleting the timer!\n"); return -1; } return 0; }
void exitTicker (rtsBool wait STG_UNUSED) { #if defined(USE_TIMER_CREATE) timer_delete(timer); // ignore errors - we don't really care if it fails. #endif }
DiaTimer :: ~DiaTimer() { #ifdef POSIX timer_delete (myTimer); #else wdDelete(timerId); // Delete the VxWorks Watchdog timer #endif return; }
OMX_ERRORTYPE OMXVideoDecoderAVCSecure::ProcessorStop(void) { if (mKeepAliveTimer != 0) { timer_delete(mKeepAliveTimer); mKeepAliveTimer = 0; } return OMXVideoDecoderBase::ProcessorStop(); }
int CTimer::DestroyTimer(){ if(m_timer != 0){ timer_delete(m_timer); m_timer = 0; } return 0; }
bool Tx_TimerDelete(Tx_TimerHandle *timer) { if(timer == NULL) return false; timer_delete(timer->timerid); free(timer); return true; }
/******************************************************************************* ** ** Function preload_stop_wait_timer ** ** Description Stop preload watchdog timer ** ** Returns None ** *******************************************************************************/ static void preload_stop_wait_timer(void) { if (preload_retry_cb.timer_created == TRUE) { timer_delete(preload_retry_cb.timer_id); preload_retry_cb.timer_created = FALSE; } }
/* * stress_timer * stress timers */ static int stress_timer(const args_t *args) { struct sigevent sev; struct itimerspec timer; sigset_t mask; uint64_t timer_freq = DEFAULT_TIMER_FREQ; (void)sigemptyset(&mask); (void)sigaddset(&mask, SIGINT); (void)sigprocmask(SIG_SETMASK, &mask, NULL); max_ops = args->max_ops; start = time_now(); if (!get_setting("timer-freq", &timer_freq)) { if (g_opt_flags & OPT_FLAGS_MAXIMIZE) timer_freq = MAX_TIMER_FREQ; if (g_opt_flags & OPT_FLAGS_MINIMIZE) timer_freq = MIN_TIMER_FREQ; } rate_ns = timer_freq ? 1000000000.0 / timer_freq : 1000000000.0; if (stress_sighandler(args->name, SIGRTMIN, stress_timer_handler, NULL) < 0) return EXIT_FAILURE; sev.sigev_notify = SIGEV_SIGNAL; sev.sigev_signo = SIGRTMIN; sev.sigev_value.sival_ptr = &timerid; if (timer_create(CLOCK_REALTIME, &sev, &timerid) < 0) { pr_fail_err("timer_create"); return EXIT_FAILURE; } stress_timer_set(&timer); if (timer_settime(timerid, 0, &timer, NULL) < 0) { pr_fail_err("timer_settime"); return EXIT_FAILURE; } do { struct timespec req; req.tv_sec = 0; req.tv_nsec = 10000000; (void)nanosleep(&req, NULL); set_counter(args, timer_counter); } while (keep_stressing()); if (timer_delete(timerid) < 0) { pr_fail_err("timer_delete"); return EXIT_FAILURE; } pr_dbg("%s: %" PRIu64 " timer overruns (instance %" PRIu32 ")\n", args->name, overruns, args->instance); return EXIT_SUCCESS; }
void StopTimerLoop(TimerCallback_t exitfunction) { EnterMutex(); if(timer_delete (timer)) { perror("timer_delete()"); } exitfunction(NULL,0); LeaveMutex(); }
void threads_linux_timer_stop_task_2(void) { int errno = 0; if(timer_delete(timer_task_2) < 0) { fprintf(stderr, "[%d]: %s\n", __LINE__, strerror(errno)); exit(errno); } }
void rb_sigio_unsched_event(struct ev_entry *event) { if(can_do_event <= 0) return; timer_delete(*((timer_t *) event->comm_ptr)); rb_free(event->comm_ptr); event->comm_ptr = NULL; }
/******************************************************************************* ** ** Function upio_cleanup ** ** Description Clean up ** ** Returns None ** *******************************************************************************/ void upio_cleanup(void) { #if (BT_WAKE_VIA_PROC == TRUE) if (lpm_proc_cb.timer_created == TRUE) timer_delete(lpm_proc_cb.timer_id); lpm_proc_cb.timer_created = FALSE; #endif }
/** * Destroys an initialized timer. If needed, the timer is first disarmed. * This function is undefined if the specified timer is not initialized. * * @warning This function <b>must</b> be called before the timer data can be * freed and before the timer callback function can be unloaded. * * @param timer to destroy */ void vlc_timer_destroy (vlc_timer_t *id) { #ifdef HAVE_POSIX_TIMER int val = timer_delete (id->handle); VLC_THREAD_ASSERT ("deleting timer"); #else timer_not_supported(); #endif }
void IntervalTimer::kill() { if (mTimerId == 0) return; timer_delete(mTimerId); mTimerId = 0; mCb = NULL; }