Example #1
0
PGM_GNUC_INTERNAL
bool
pgm_time_shutdown (void)
{
	bool retval = TRUE;

	pgm_return_val_if_fail (pgm_atomic_read32 (&time_ref_count) > 0, FALSE);

	if (pgm_atomic_exchange_and_add32 (&time_ref_count, (uint32_t)-1) != 1)
		return retval;

#ifdef _WIN32
	timeEndPeriod (wTimerRes);
#endif

#ifdef HAVE_DEV_RTC
	if (pgm_time_update_now == pgm_rtc_update)
		retval = pgm_rtc_shutdown ();
#endif
#ifdef HAVE_DEV_HPET
	if (pgm_time_update_now == pgm_hpet_update)
		retval = pgm_hpet_shutdown ();
#endif
	return retval;
}
Example #2
0
void
pgm_messages_shutdown (void)
{
	pgm_return_if_fail (pgm_atomic_read32 (&messages_ref_count) > 0);

	if (pgm_atomic_exchange_and_add32 (&messages_ref_count, (uint32_t)-1) != 1)
		return;

	pgm_mutex_free (&messages_mutex);
}
Example #3
0
PGM_GNUC_INTERNAL
void
pgm_rand_shutdown (void)
{
	pgm_return_if_fail (pgm_atomic_read32 (&rand_ref_count) > 0);

	if (pgm_atomic_exchange_and_add32 (&rand_ref_count, (uint32_t)-1) != 1)
		return;

	pgm_mutex_free (&rand_mutex);
}
Example #4
0
pgm_log_func_t
pgm_log_set_handler (
	pgm_log_func_t		handler,
	void*			closure
	)
{
	pgm_log_func_t previous_handler;
	const uint32_t count = pgm_atomic_read32 (&messages_ref_count);

/* cannot use mutexes for initialising log handler before pgm_init() for
 * locking systems that do not accept static initialization, e.g. Windows
 * critical sections.
 */
	if (count > 0) pgm_mutex_lock (&messages_mutex);
	previous_handler	= log_handler;
	log_handler		= handler;
	log_handler_closure	= closure;
	if (count > 0) pgm_mutex_unlock (&messages_mutex);
	return previous_handler;
}