Ejemplo n.º 1
0
	void syserr(const char * msg)
	{
		if(current_game == error_game)
			return;

		std::cerr << msg << std::endl;
		suspend();
		message(msg, love::TAG_ERROR);
	}
Ejemplo n.º 2
0
void osd_state::switch_to_internal_video_mode()
{
    if ( m_current_state != suspended){
      suspend();
    }
    m_current_state = internal_video;
    detail::video_setup();

}
Ejemplo n.º 3
0
// release releases the interface to the font object 
//
void APIText::release() {

  suspend();

  if (d3dfont) {
    d3dfont->Release();
    d3dfont = nullptr;
  }
}
Ejemplo n.º 4
0
int main ( int argc, char **argv )
{
	int mode = 0;
	int ac_resusp = 0;
	int fix_rtc = 0;
	int opt;

	while (( opt = getopt ( argc, argv, "a:frs" )) != EOF ) {
		switch ( opt ) {
			case 's':
				mode = 's';
				break;
			case 'r':
				mode = 'r';
				break;
			case 'a':
				ac_resusp = atoi ( optarg );
				if ( ac_resusp < 30 ) {
					ac_resusp = 120;

					fprintf ( stderr, "Warning: resuspend timeout must be >= 30 sec. -- now set to 120 sec\n" );
				}
				break;
			case 'f':
				fix_rtc = 1;
				break;
			default:
				usage ( );
		}
	}

	if ( geteuid ( ) != 0 ) {
		fprintf ( stderr, "You need root priviledges to run opiealarm." );
		return 2;
	}

	if ( !mode )
		usage ( );


	parent_pid = getpid ( );

	// kill running opiealarm
	opiealarm_was_running = kill_with_pidfile ( );
	remove_pidfile ( );

	switch ( mode ) {
		case 'r': opt = resume ( ac_resusp );
		          break;
		case 's':
		default : opt = suspend ( fix_rtc );
		          break;
	}

	parent_pid = 0;
	return opt;
}
Ejemplo n.º 5
0
bool mutex::lock(const bool wait) {
    const THREAD_ID lock_id = get_thread_id();
    
    while(atomic_if_then_assign(&_mutex_owner, lock_id, 0) != 0) {
        if (wait) suspend(0);
        else return false;
    }
    return true;
}
void TVDemo::shell()
{
    suspend();
    system("cls");
    cout << "Type EXIT to return...";
    system( getenv( "COMSPEC"));
    resume();
    redraw();
}
Ejemplo n.º 7
0
	void syswarn(const char * msg)
	{
		if(current_game == error_game)
			return;

		std::cerr << msg << std::endl;
		suspend();
		message(msg, love::TAG_WARNING);
	}
Ejemplo n.º 8
0
void 
C64::setNTSC()
{
    debug(2, "C64::setNTSC\n");

	suspend();
    vic.setChipModel(MOS6567_NTSC);
	sid.setNTSC();
	resume();
}
Ejemplo n.º 9
0
void
C64::setPAL()
{
    debug(2, "C64::setPAL\n");

    suspend();
    vic.setChipModel(MOS6569_PAL);
	sid.setPAL();
	resume();
}
Ejemplo n.º 10
0
/*
 * *************************************************************
 * Clean up and terminate with exitcode given as argument
 * *************************************************************
*/
void cleanup_and_exit( srv_opts_t *options )
{
   // cleanup e.g. free allocated pointers
   if( options != NULL )
   {
   }

   // and suspend process
   suspend( options );
}
Ejemplo n.º 11
0
void
KcsPower::releaseButton(unsigned nr)
{
    if (nr == 1) {
    
        suspend();
        c64->cpu.releaseNmiLine(CPU::INTSRC_EXPANSION);
        resume();
    }
};
Ejemplo n.º 12
0
void Search::exit() {
	exitsearch = true;
	suspend();
	resume();
	if (worker.joinable()) {
		worker.join();
	}
	timer.stop();
	stageTimer.stop();
}
Ejemplo n.º 13
0
void ScriptTcl::runController(int task) {
  scriptBarrier.publish(barrierStep++,task);
  suspend();
#ifdef NAMD_TCL
  if ( task == SCRIPT_RUN || task == SCRIPT_CONTINUE || task == SCRIPT_MINIMIZE  ) {
    doCallback(state->callback_labelstring.c_str(),
               state->callback_valuestring.c_str());
  }
#endif
}
Ejemplo n.º 14
0
void
C64::setPAL()
{
	suspend();
	
    vic->setChipModel(MOS6569_PAL);
	sid->setPAL();

    debug(2, "Switching VIC chip model to MOS6569 (PAL)\n");
	resume();
}
Ejemplo n.º 15
0
void 
C64::setNTSC()
{
	suspend();
	    
    vic->setChipModel(MOS6567_NTSC);
	sid->setNTSC();

    debug(2, "Switching VIC chip model to MOS6567 (NTSC)\n");
	resume();
}
Ejemplo n.º 16
0
int
__pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock,
			      const struct timespec *abstime)
{
  pthread_descr self;
  pthread_extricate_if extr;

  if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
    return EINVAL;

  self = thread_self ();

  /* Set up extrication interface */
  extr.pu_object = rwlock;
  extr.pu_extricate_func =  rwlock_wr_extricate_func;

  /* Register extrication interface */
  __pthread_set_own_extricate_if (self, &extr);

  while(1)
    {
      __pthread_lock (&rwlock->__rw_lock, self);

      if (rwlock->__rw_readers == 0 && rwlock->__rw_writer == NULL)
	{
	  rwlock->__rw_writer = self;
	  __pthread_set_own_extricate_if (self, 0);
	  __pthread_unlock (&rwlock->__rw_lock);
	  return 0;
	}

      /* Suspend ourselves, then try again */
      enqueue (&rwlock->__rw_write_waiting, self);
      __pthread_unlock (&rwlock->__rw_lock);
      /* This is not a cancellation point */
      if (timedsuspend (self, abstime) == 0)
	{
	  int was_on_queue;

	  __pthread_lock (&rwlock->__rw_lock, self);
	  was_on_queue = remove_from_queue (&rwlock->__rw_write_waiting, self);
	  __pthread_unlock (&rwlock->__rw_lock);

	  if (was_on_queue)
	    {
	      __pthread_set_own_extricate_if (self, 0);
	      return ETIMEDOUT;
	    }

	  /* Eat the outstanding restart() from the signaller */
	  suspend (self);
	}
    }
}
Ejemplo n.º 17
0
void device_execute_interface::interface_pre_reset()
{
	// reset the total number of cycles
	m_totalcycles = 0;

	// enable all devices (except for disabled devices)
	if (!disabled())
		resume(SUSPEND_ANY_REASON);
	else
		suspend(SUSPEND_REASON_DISABLE, true);
}
Ejemplo n.º 18
0
void
genunimp ()
{
    console_reset();
#ifdef PCHIST
    ppc();
#endif /* PCHIST */
    suspend();
    console_init();

    return;
}
Ejemplo n.º 19
0
void yarn_suspend_on_time ( unsigned long usecs )
{
	yarn_t currentYarn;
	unsigned long i;
	TTDGET();
	currentYarn = TTD.yarn_current->pid;
	wait_graph_lock(wg);
	wait_graph_insert(wg, currentYarn);
	wait_graph_insert_time(wg, currentYarn, yarns_time() + usecs);
	wait_graph_unlock(wg);
	suspend();
}
Ejemplo n.º 20
0
		void suspend_for(const boost::posix_time::time_duration& timeout, Callback&& cancel)
		{
			timer_.expires_from_now(timeout);

			timer_.async_wait(
				[&](const boost::system::error_code&)
			{
				resume();
			});

			suspend();

			timer_.cancel();

			cancel();

			suspend();

			if (interrupted_)
				BOOST_THROW_EXCEPTION(interrupted_exception());
		}
Ejemplo n.º 21
0
void
KcsPower::pressButton(unsigned nr)
{
    if (nr == 1) {
 
        // Pressing the button triggers an NMI in Ultimax mode
        suspend();
        c64->expansionport.setCartridgeMode(CRT_ULTIMAX);
        c64->cpu.pullDownNmiLine(CPU::INTSRC_EXPANSION);
        resume();
    }
};
Ejemplo n.º 22
0
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
    struct userdata *u = PA_SINK(o)->userdata;

    switch (code) {

        case PA_SINK_MESSAGE_GET_LATENCY:
            *((pa_usec_t*) data) = sink_get_latency(u, &PA_SINK(o)->sample_spec);
            return 0;

        case PA_SINK_MESSAGE_SET_STATE:

            switch ((pa_sink_state_t) PA_PTR_TO_UINT(data)) {

                case PA_SINK_SUSPENDED:

                    pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));

                    pa_smoother_pause(u->smoother, pa_rtclock_now());

                    if (!u->source || u->source_suspended) {
                        if (suspend(u) < 0)
                            return -1;
                    }
                    u->sink_suspended = true;
                    break;

                case PA_SINK_IDLE:
                case PA_SINK_RUNNING:

                    if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
                        pa_smoother_resume(u->smoother, pa_rtclock_now(), true);

                        if (!u->source || u->source_suspended) {
                            if (unsuspend(u) < 0)
                                return -1;
                            u->sink->get_volume(u->sink);
                            u->sink->get_mute(u->sink);
                        }
                        u->sink_suspended = false;
                    }
                    break;

                case PA_SINK_INVALID_STATE:
                case PA_SINK_UNLINKED:
                case PA_SINK_INIT:
                    ;
            }

            break;
    }

    return pa_sink_process_msg(o, code, data, offset, chunk);
}
Ejemplo n.º 23
0
static void task_purger(rtems_task_argument arg)
{
  while (true) {
    suspend(RTEMS_SELF);

    set_task_prio(RTEMS_SELF, PRIORITY_HIGH);

    purge('P');
  }

  rtems_task_delete(RTEMS_SELF);
}
Ejemplo n.º 24
0
void f()
{
  int i=0,flag=0;
  while(1){
    printf("tid :%d in f: %d\n",getID(),i++);
    if(i>0 && !flag) {
	suspend(tid);
	flag = 1;		
    }
    usleep(90000);
  }
}
Ejemplo n.º 25
0
Archivo: kbd.c Proyecto: PyroOS/Pyro
static int kbd_read( void* pNode, void* pCookie, off_t nPos, void* pBuf, size_t nLen )
{
    KbdVolume_s* 	psVolume = &g_sVolume;
    int		nError;
    if ( 0 == nLen ) {
	return( 0 );
    }
	
    for ( ;; )
    {
    	if ( atomic_read( &psVolume->nBytesReceived ) > 0 )
	{
	    int	nSize = min( nLen, atomic_read( &psVolume->nBytesReceived ) );
	    int	i;
	    char*	pzBuf = pBuf;

	    for ( i = 0 ; i < nSize ; ++i ) {
		pzBuf[ i ] = psVolume->zBuffer[ atomic_inc_and_read( &psVolume->nOutPos ) & 0xff ];
	    }
	    atomic_sub( &g_sVolume.nBytesReceived, nSize );
			
	    nError = nSize;
	}
	else
	{
	    int	nEFlg = cli();

	    if ( -1 != psVolume->hWaitThread )
	    {
		nError = -EBUSY;
		printk( "ERROR : two threads attempted to read from keyboard device!\n" );
	    }
	    else
	    {
		if ( 1 )
		{
		    nError = -EWOULDBLOCK;
		}
		else
		{
		    psVolume->hWaitThread = get_thread_id(NULL);
		    nError = suspend();
		    psVolume->hWaitThread = -1;
		}
	    }
	    put_cpu_flags( nEFlg );
	}
	if ( 0 != nError ) {
	    break;
	}
    }
    return( nError );
}
Ejemplo n.º 26
0
void Game::update(float interval)
{
	updateEnvironment(interval);
	switch (mGameState) {
		case STATE_MENU:
			break;
		case STATE_WAITING:
			updateBall(sgoBall, interval);

			if ((sgoBall.pos() - sgLookat).len() < 1.0f)
			{
				mCounter = 0.0f;
				mGameState = STATE_COUNTDOWN;
			}
			break;
		case STATE_COUNTDOWN:
			mCounter += interval;
			if (mCounter > COUNTDOWN_TIME)
			{
				enableBall();
				mGameState = STATE_RUNNING;
			}
		case STATE_RUNNING:
		if (wasKeyPressed(KEY_ESC))
		{
			Main::pushState(gScreenMain2);
		}

		/* manually switch features */
		if (wasFunctionPressed(1))
		{
			setBallShadow(!useBallShadow());
		}

		if (wasFunctionPressed(2))
		{
			setReflection(!useReflection());
		}

		if (wasFunctionPressed(5))
		{
			suspend();
			toggleMouseControl();
			resume();
		}

		updateBall(sgoBall, interval);
			break;
	}

	updateGameField(sgoBall);
}
Ejemplo n.º 27
0
static void test_scheduler_move_heir(void)
{
  bool per_cpu_state_ok;

  _Thread_Disable_dispatch();

  suspend(2);
  suspend(3);
  suspend(0);
  resume(2);
  suspend(1);
  resume(3);
  resume(0);

  per_cpu_state_ok = is_per_cpu_state_ok();

  resume(1);

  _Thread_Enable_dispatch();

  rtems_test_assert(per_cpu_state_ok);
}
Ejemplo n.º 28
0
bool Thread::shutdown(){
	// The thread will cleanly exit when it is done
	running=false;
	suspend();

	// Now wait for the thread to shutdown
	WaitForSingleObject(thread,INFINITE);

	// It's destroyed, let's set our handle back to null
	thread=NULL;

	return true;
}
Ejemplo n.º 29
0
bool
C64::insertTape(TAPArchive *a)
{
    if (a == NULL)
        return false;
    
    suspend();
    debug("Inserting tape %p\n", a);
    datasette.insertTape(a);
    resume();
    
    return true;
}
Ejemplo n.º 30
0
Vst2413r::Vst2413r(audioMasterCallback audioMaster)
:   AudioEffectX(audioMaster, 0, 0),
    driver_(44100)
{
    if(audioMaster != NULL) {
        setNumInputs(0);
        setNumOutputs(1);
        setUniqueID(kUniqueId);
        canProcessReplacing();
        isSynth();
    }
    suspend();
}