• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PANIC函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PANIC函数的典型用法代码示例。如果您正苦于以下问题:C++ PANIC函数的具体用法?C++ PANIC怎么用?C++ PANIC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PANIC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: init_private

static void
init_private(void)
{
	struct rlimit rlim;
	size_t len;
	int mib[2];
	char *env, *env_bigstack, *env_splitstack;

	_thr_umutex_init(&_mutex_static_lock);
	_thr_umutex_init(&_cond_static_lock);
	_thr_umutex_init(&_rwlock_static_lock);
	_thr_umutex_init(&_keytable_lock);
	_thr_urwlock_init(&_thr_atfork_lock);
	_thr_umutex_init(&_thr_event_lock);
	_thr_umutex_init(&_suspend_all_lock);
	_thr_once_init();
	_thr_spinlock_init();
	_thr_list_init();
	_thr_wake_addr_init();
	_sleepq_init();
	_single_thread = NULL;
	_suspend_all_waiters = 0;

	/*
	 * Avoid reinitializing some things if they don't need to be,
	 * e.g. after a fork().
	 */
	if (init_once == 0) {
		/* Find the stack top */
		mib[0] = CTL_KERN;
		mib[1] = KERN_USRSTACK;
		len = sizeof (_usrstack);
		if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
			PANIC("Cannot get kern.usrstack from sysctl");
		env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN");
		env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN");
		if (env_bigstack != NULL || env_splitstack == NULL) {
			if (getrlimit(RLIMIT_STACK, &rlim) == -1)
				PANIC("Cannot get stack rlimit");
			_thr_stack_initial = rlim.rlim_cur;
		}
		len = sizeof(_thr_is_smp);
		sysctlbyname("kern.smp.cpus", &_thr_is_smp, &len, NULL, 0);
		_thr_is_smp = (_thr_is_smp > 1);
		_thr_page_size = getpagesize();
		_thr_guard_default = _thr_page_size;
		_pthread_attr_default.guardsize_attr = _thr_guard_default;
		_pthread_attr_default.stacksize_attr = _thr_stack_default;
		env = getenv("LIBPTHREAD_SPINLOOPS");
		if (env)
			_thr_spinloops = atoi(env);
		env = getenv("LIBPTHREAD_YIELDLOOPS");
		if (env)
			_thr_yieldloops = atoi(env);
		env = getenv("LIBPTHREAD_QUEUE_FIFO");
		if (env)
			_thr_queuefifo = atoi(env);
		TAILQ_INIT(&_thr_atfork_list);
	}
	init_once = 1;
}
开发者ID:cemeyer,项目名称:freebsd-base-graphics,代码行数:61,代码来源:thr_init.c


示例2: processtypes

/* 3. mark types that use vlen*/
static void
processtypes(void)
{
    int i,j,keep,added;
    List* sorted = listnew(); /* hold re-ordered type set*/
    /* Prime the walk by capturing the set*/
    /*     of types that are dependent on primitive types*/
    /*     e.g. uint vlen(*) or primitive types*/
    for(i=0;i<listlength(typdefs);i++) {
        Symbol* sym = (Symbol*)listget(typdefs,i);
	keep=0;
	switch (sym->subclass) {
	case NC_PRIM: /*ignore pre-defined primitive types*/
	    sym->touched=1;
	    break;
	case NC_OPAQUE:
	case NC_ENUM:
	    keep=1;
	    break;
        case NC_VLEN: /* keep if its basetype is primitive*/
	    if(sym->typ.basetype->subclass == NC_PRIM) keep=1;
	    break;	    	
	case NC_COMPOUND: /* keep if all fields are primitive*/
	    keep=1; /*assume all fields are primitive*/
	    for(j=0;j<listlength(sym->subnodes);j++) {
		Symbol* field = (Symbol*)listget(sym->subnodes,j);
		ASSERT(field->subclass == NC_FIELD);
		if(field->typ.basetype->subclass != NC_PRIM) {keep=0;break;}
	    }	  
	    break;
	default: break;/* ignore*/
	}
	if(keep) {
	    sym->touched = 1;
	    listpush(sorted,(void*)sym);
	}
    }	
    /* 2. repeated walk to collect level i types*/
    do {
        added=0;
        for(i=0;i<listlength(typdefs);i++) {
	    Symbol* sym = (Symbol*)listget(typdefs,i);
	    if(sym->touched) continue; /* ignore already processed types*/
	    keep=0; /* assume not addable yet.*/
	    switch (sym->subclass) {
	    case NC_PRIM: 
	    case NC_OPAQUE:
	    case NC_ENUM:
		PANIC("type re-touched"); /* should never happen*/
	        break;
            case NC_VLEN: /* keep if its basetype is already processed*/
	        if(sym->typ.basetype->touched) keep=1;
	        break;	    	
	    case NC_COMPOUND: /* keep if all fields are processed*/
	        keep=1; /*assume all fields are touched*/
	        for(j=0;j<listlength(sym->subnodes);j++) {
		    Symbol* field = (Symbol*)listget(sym->subnodes,j);
		    ASSERT(field->subclass == NC_FIELD);
		    if(!field->typ.basetype->touched) {keep=1;break;}
	        }	  
	        break;
	    default: break;				
	    }
	    if(keep) {
		listpush(sorted,(void*)sym);
		sym->touched = 1;
		added++;
	    }	    
	}
    } while(added > 0);
    /* Any untouched type => circular dependency*/
    for(i=0;i<listlength(typdefs);i++) {
	Symbol* tsym = (Symbol*)listget(typdefs,i);
	if(tsym->touched) continue;
	semerror(tsym->lineno,"Circular type dependency for type: %s",fullname(tsym));
    }
    listfree(typdefs);
    typdefs = sorted;
    /* fill in type typecodes*/
    for(i=0;i<listlength(typdefs);i++) {
        Symbol* sym = (Symbol*)listget(typdefs,i);
	if(sym->typ.basetype != NULL && sym->typ.typecode == NC_NAT)
	    sym->typ.typecode = sym->typ.basetype->typ.typecode;
    }
    /* Identify types containing vlens */
    for(i=0;i<listlength(typdefs);i++) {
        Symbol* tsym = (Symbol*)listget(typdefs,i);
	tagvlentypes(tsym);
    }
}
开发者ID:brandontheis,项目名称:netcdf-1,代码行数:91,代码来源:semantics.c


示例3: init_main_thread

/*
 * This function and pthread_create() do a lot of the same things.
 * It'd be nice to consolidate the common stuff in one place.
 */
static void
init_main_thread(struct pthread *thread)
{
	struct sched_param sched_param;

	/* Setup the thread attributes. */
	thr_self(&thread->tid);
	thread->attr = _pthread_attr_default;
	/*
	 * Set up the thread stack.
	 *
	 * Create a red zone below the main stack.  All other stacks
	 * are constrained to a maximum size by the parameters
	 * passed to mmap(), but this stack is only limited by
	 * resource limits, so this stack needs an explicitly mapped
	 * red zone to protect the thread stack that is just beyond.
	 */
	if (mmap(_usrstack - _thr_stack_initial -
	    _thr_guard_default, _thr_guard_default, 0, MAP_ANON,
	    -1, 0) == MAP_FAILED)
		PANIC("Cannot allocate red zone for initial thread");

	/*
	 * Mark the stack as an application supplied stack so that it
	 * isn't deallocated.
	 *
	 * XXX - I'm not sure it would hurt anything to deallocate
	 *       the main thread stack because deallocation doesn't
	 *       actually free() it; it just puts it in the free
	 *       stack queue for later reuse.
	 */
	thread->attr.stackaddr_attr = _usrstack - _thr_stack_initial;
	thread->attr.stacksize_attr = _thr_stack_initial;
	thread->attr.guardsize_attr = _thr_guard_default;
	thread->attr.flags |= THR_STACK_USER;

	/*
	 * Write a magic value to the thread structure
	 * to help identify valid ones:
	 */
	thread->magic = THR_MAGIC;

	thread->cancel_enable = 1;
	thread->cancel_async = 0;

	/* Initialize the mutex queue: */
	TAILQ_INIT(&thread->mutexq);
	TAILQ_INIT(&thread->pp_mutexq);

	thread->state = PS_RUNNING;

	_thr_getscheduler(thread->tid, &thread->attr.sched_policy,
		 &sched_param);
	thread->attr.prio = sched_param.sched_priority;

#ifdef _PTHREAD_FORCED_UNWIND
	thread->unwind_stackend = _usrstack;
#endif

	/* Others cleared to zero by thr_alloc() */
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:65,代码来源:thr_init.c


示例4: _pthread_exit

void
_pthread_exit(void *status)
{
	struct pthread *curthread = _get_curthread();
	kse_critical_t crit;
	struct kse *curkse;

	/* Check if this thread is already in the process of exiting: */
	if ((curthread->flags & THR_FLAGS_EXITING) != 0) {
		char msg[128];
		snprintf(msg, sizeof(msg), "Thread %p has called "
		    "pthread_exit() from a destructor. POSIX 1003.1 "
		    "1996 s16.2.5.2 does not allow this!", curthread);
		PANIC(msg);
	}

	/*
	 * Flag this thread as exiting.  Threads should now be prevented
	 * from joining to this thread.
	 */
	THR_SCHED_LOCK(curthread, curthread);
	curthread->flags |= THR_FLAGS_EXITING;
	THR_SCHED_UNLOCK(curthread, curthread);
	
	/*
	 * To avoid signal-lost problem, if signals had already been
	 * delivered to us, handle it. we have already set EXITING flag
	 * so no new signals should be delivered to us.
	 * XXX this is not enough if signal was delivered just before
	 * thread called sigprocmask and masked it! in this case, we
	 * might have to re-post the signal by kill() if the signal
	 * is targeting process (not for a specified thread).
	 * Kernel has same signal-lost problem, a signal may be delivered
	 * to a thread which is on the way to call sigprocmask or thr_exit()!
	 */
	if (curthread->check_pending)
		_thr_sig_check_pending(curthread);
	/* Save the return value: */
	curthread->ret = status;
	while (curthread->cleanup != NULL) {
		_pthread_cleanup_pop(1);
	}
	if (curthread->attr.cleanup_attr != NULL) {
		curthread->attr.cleanup_attr(curthread->attr.arg_attr);
	}
	/* Check if there is thread specific data: */
	if (curthread->specific != NULL) {
		/* Run the thread-specific data destructors: */
		_thread_cleanupspecific();
	}
	if (!_kse_isthreaded())
		exit(0);
	crit = _kse_critical_enter();
	curkse = _get_curkse();
	KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock);
	/* Use thread_list_lock */
	_thread_active_threads--;
	if ((_thread_scope_system <= 0 && _thread_active_threads == 1) ||
	    (_thread_scope_system > 0 && _thread_active_threads == 0)) {
		KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
		_kse_critical_leave(crit);
		exit(0);
		/* Never reach! */
	}
	KSE_LOCK_RELEASE(curkse, &_thread_list_lock);

	/* This thread will never be re-scheduled. */
	KSE_LOCK(curkse);
	THR_SET_STATE(curthread, PS_DEAD);
	_thr_sched_switch_unlocked(curthread);
	/* Never reach! */

	/* This point should not be reached. */
	PANIC("Dead thread has resumed");
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:75,代码来源:thr_exit.c


示例5: __ASSERT_DEBUG

// The static Cast method is used to obtain a pointer to the derived class object
EXPORT_C TLinkKeyNotificationEvent& TLinkKeyNotificationEvent::Cast(const THCIEventBase& aEvent)
	{
	__ASSERT_DEBUG(aEvent.EventCode() == ELinkKeyNotificationEvent, PANIC(KSymbianCommandsEventsPanicCat, EWrongEventCode));
	return *(reinterpret_cast<TLinkKeyNotificationEvent*>(&const_cast<THCIEventBase&>(aEvent)));
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:6,代码来源:linkkeynotificationevent.cpp


示例6: _pthread_exit

void
_pthread_exit(void *status)
{
	struct pthread *curthread = _get_curthread();

	/* Check if this thread is already in the process of exiting: */
	if (curthread->cancelling) {
		char msg[128];
		snprintf(msg, sizeof(msg), "Thread %p has called "
		    "pthread_exit() from a destructor. POSIX 1003.1 "
		    "1996 s16.2.5.2 does not allow this!", curthread);
		PANIC(msg);
	}

	/* Flag this thread as exiting. */
	curthread->cancelling = 1;
	
	_thr_exit_cleanup();

	/* Save the return value: */
	curthread->ret = status;
	while (curthread->cleanup != NULL) {
		_pthread_cleanup_pop(1);
	}

	/* Check if there is thread specific data: */
	if (curthread->specific != NULL) {
		/* Run the thread-specific data destructors: */
		_thread_cleanupspecific();
	}

	if (!_thr_isthreaded())
		exit(0);

	THREAD_LIST_LOCK(curthread);
	_thread_active_threads--;
	if (_thread_active_threads == 0) {
		THREAD_LIST_UNLOCK(curthread);
		exit(0);
		/* Never reach! */
	}
	THREAD_LIST_UNLOCK(curthread);

	/* Tell malloc that the thread is exiting. */
	_malloc_thread_cleanup();

	THREAD_LIST_LOCK(curthread);
	THR_LOCK(curthread);
	curthread->state = PS_DEAD;
	if (curthread->flags & THR_FLAGS_NEED_SUSPEND) {
		curthread->cycle++;
		_thr_umtx_wake(&curthread->cycle, INT_MAX, 0);
	}
	THR_UNLOCK(curthread);
	/*
	 * Thread was created with initial refcount 1, we drop the
	 * reference count to allow it to be garbage collected.
	 */
	curthread->refcount--;
	if (curthread->tlflags & TLFLAGS_DETACHED)
		THR_GCLIST_ADD(curthread);
	THREAD_LIST_UNLOCK(curthread);
	if (!curthread->force_exit && SHOULD_REPORT_EVENT(curthread, TD_DEATH))
		_thr_report_death(curthread);

	/*
	 * Kernel will do wakeup at the address, so joiner thread
	 * will be resumed if it is sleeping at the address.
	 */
	thr_exit(&curthread->tid);
#ifndef __AVM2__ // might exit if we're impersonating another thread!
	PANIC("thr_exit() returned");
#endif
	/* Never reach! */
}
开发者ID:5432935,项目名称:crossbridge,代码行数:75,代码来源:thr_exit.c


示例7: PANIC_IF

void spawner_new_c::setup_stream_(const std::string& stream_str, pipes_t this_pipe_type, runner* this_runner) {
    size_t pos = stream_str.find(".");
    // malformed argument
    PANIC_IF(pos == std::string::npos);
    size_t index = stoi(stream_str.substr(1, pos - 1), nullptr, 10);
    std::string stream = stream_str.substr(pos + 1);
    // invalid index
    PANIC_IF(index >= runners.size() || index < 0);
    pipes_t other_pipe_type;
    if (stream == "stderr") {
        other_pipe_type = STD_ERROR_PIPE;
    }
    else if (stream == "stdin") {
        other_pipe_type = STD_INPUT_PIPE;
    }
    else if (stream == "stdout") {
        other_pipe_type = STD_OUTPUT_PIPE;
    }
    else {
        PANIC("invalid stream name");
    }
    runner *target_runner = runners[index];
    std::shared_ptr<input_pipe_c> input_pipe = nullptr;
    std::shared_ptr<output_pipe_c> output_pipe = nullptr;
    pipes_t out_pipe_type = STD_ERROR_PIPE;
    runner* out_pipe_runner = nullptr;
    runner* in_pipe_runner = nullptr;

    if (this_pipe_type == STD_INPUT_PIPE && other_pipe_type != STD_INPUT_PIPE) {

        input_pipe = std::static_pointer_cast<input_pipe_c>(this_runner->get_pipe(this_pipe_type));
        output_pipe = std::static_pointer_cast<output_pipe_c>(target_runner->get_pipe(other_pipe_type));
        out_pipe_type = other_pipe_type;
        out_pipe_runner = target_runner;
        in_pipe_runner = this_runner;

    } else if (this_pipe_type != STD_INPUT_PIPE && other_pipe_type == STD_INPUT_PIPE) {

        input_pipe = std::static_pointer_cast<input_pipe_c>(target_runner->get_pipe(other_pipe_type));
        output_pipe = std::static_pointer_cast<output_pipe_c>(this_runner->get_pipe(this_pipe_type));
        out_pipe_type = this_pipe_type;
        out_pipe_runner = this_runner;
        in_pipe_runner = target_runner;
    } else {
        PANIC("invalid pipe mapping");
    }

    std::shared_ptr<duplex_buffer_c> buffer = std::make_shared<duplex_buffer_c>();
    in_pipe_runner->duplex_buffers.push_back(buffer);
    out_pipe_runner->duplex_buffers.push_back(buffer);
    input_pipe->add_input_buffer(buffer);
    output_pipe->add_output_buffer(buffer);

    int out_runner_index = -1;
    int in_runner_index = -1;
    for (size_t i = 0; i < runners.size(); i++) {
        if (runners[i] == out_pipe_runner) {
            out_runner_index = i;
        }
        if (runners[i] == in_pipe_runner) {
            in_runner_index = i;
        }
    }

    if (out_runner_index == controller_index_) {
        int index = in_runner_index;
        if (index > controller_index_) {
            index--;
        }
        buffer_to_runner_index_[buffer] = index + 1;
    }

    if (control_mode_enabled
            && out_pipe_type == STD_OUTPUT_PIPE
            && !output_pipe->process_message) {

        if (out_pipe_runner->get_options().controller) {
            output_pipe->process_message = [=](const std::string& message, output_pipe_c* pipe) {
                process_controller_message_(message, pipe);
            };
        } else {
            int index = out_runner_index;
            if (index > controller_index_) {
                index--;
            }
            output_pipe->process_message = [=](const std::string& message, output_pipe_c* pipe) {
                process_normal_message_(message, pipe, index + 1);
            };
        }
    }
}
开发者ID:klenin,项目名称:Spawner,代码行数:91,代码来源:spawner_new.cpp


示例8: address

/*!
  \class Worker
  Run worker.
  \public
  @param[in] server_name Server IP address (ex: 127.0.0.1).
  @param[in] port The port number (ex: 80).
*/
void Worker::run(char* server_name, char* port)
{
  // Create new socket class instance.
  Socket *socket = new Socket();
  
  // Connect to the server.
  socket->connect_(server_name, port);
  
  std::string hello = WORKER_HELLO;
  
  // "Introduce yourself to the server".
  socket->send_(hello);

  std::string data_result = "";
  std::string data_errors = "";
  std::string data_inf = "";
  std::string data_to_send = "";
  std::string data_filename = "";
  
  std::string data_recive = "";

  std::string compile_result = "";
  char ch;
  int pos1, pos2;

  while(true)
  {
    data_result = "";
    data_recive = "";
    data_errors = "";
    data_filename = "";
    data_inf = "";
    pos1 = 0;
    pos2 = 0;

    if (!SELF_DEBUG)
    {
	std::cout << "Czekam na dane...\n";

        try
        {
          data_recive = socket->recive_();
        }
        catch(char *str)
        {
           PANIC(-1, str);
        }
        catch(...)
        {
           PANIC(-1, "Exception..");
        }
    }
    else
    {
         data_recive = DEBUG_SOURCE;
    }

    pos1 = data_recive.find(DATA_SEPARATOR);
    pos2 = data_recive.find(DATA_SEPARATOR, pos1+1,16);
    data_filename = data_recive.substr(0, pos1);
    data_recive = data_recive.substr(pos1+16, pos2-25);
    
    // Write data from client to the file.
    File::write(INPUT_FILE, data_recive);

    /*
    FILE* fp = fopen(INPUT_FILE, "w");
    fprintf(fp,"%s",data_recive.c_str() );
    fclose(fp);
    */

    // Get g++ compiler version.
    std::cout << "Zbieram dane o kompilatorze...\n";
    system("g++ -v 2>inf.sr");
    
    //std::string result;
    //char tmp[1024];
    //FILE *term = popen("g++4 -c -o output.o output.cpp", "r");
    
    //while((fgets(tmp, 1024, term)) != 0)
    //{
    //     result += std::string(tmp);
    //     tmp[0] = '\0';
    //}

    // Compling...
    std::cout << "Kompiluje dane...\n";
    system("./bash_create_output");
    //system("python ./x.rb");
    system("g++ -c -o output.o output.cpp 2> errors.sr");
    //execl("/bin/sh","./bash_compile","bash_compile", NULL);
    
    // Get results from files using File namespace.
//.........这里部分代码省略.........
开发者ID:OlaJakubowicz,项目名称:porpe,代码行数:101,代码来源:Worker.cpp


示例9: page_fault

void page_fault(struct TrapFrame * tf)
{
	PANIC("Page fault!");
}
开发者ID:yemxx,项目名称:shayang,代码行数:4,代码来源:page.c


示例10: switch

void CSdlAppServ::RunL()
    {
    if(iStatus == KErrNone)
        {
        switch(iService)
            {
            case CSdlAppServ::EAppSrvWaitDsa:
            	//EpocSdlEnv::SetWaitDsa();
            	iReturnValue = EpocSdlEnv::IsDsaAvailable();
            	break;
           	/* case CSdlAppServ::EAppSrvStopThread:
           	 	if(gEpocEnv->iDsa != NULL)
            		gEpocEnv->iDsa->SetSuspend();
            	break;*/
            case EpocSdlEnv::EDisableKeyBlocking:
                EnvUtils::DisableKeyBlocking();
                break;
         
            case EpocSdlEnv::ESetAppOrientation:
                iReturnValue = EnvUtils::SetAppOrientation(static_cast<CSDL::TAppOrientation>(iReturnValue));
                break;    
                
           
            case EAppSrvWindowPointerCursorMode:
                iReturnValue = gEpocEnv->iDsa != NULL ?
                 gEpocEnv->iDsa->Session().PointerCursorMode() : KErrNotReady; 
                break;
                
            case EAppSrvDsaStatus:
            	if(gEpocEnv->iDsa != NULL)
            		gEpocEnv->iDsa->Stop();
                iReturnValue = KErrNone;
                break;
            case CDsa::ERequestUpdate:
            	gEpocEnv->iDsa->UnlockHWSurfaceRequestComplete();
            	break;
            case EVideoUpdate:
                VideoUpdate();
                break;
            case EAppSrvNoop:
                break;
            case MSDLObserver::EEventResume:
            case MSDLObserver::EEventSuspend:
            case MSDLObserver::EEventScreenSizeChanged:
            case MSDLObserver::EEventWindowReserved:
            case MSDLObserver::EEventKeyMapInit:
            case MSDLObserver::EEventWindowNotAvailable:
            case MSDLObserver::EEventMainExit:
            case MSDLObserver::EEventVolumeChange:
            case MSDLObserver::EEventScreenSurfaceCreated:
            	iReturnValue = ObserverEvent(iService, iReturnValue);
            	HandleObserverValue(iService, iReturnValue, ETrue);
            	break;
            default:
                PANIC(KErrNotSupported);
            }
       /*
        iStatus = KRequestPending;
        iStatusPtr = &iStatus;
        SetActive();
        */
        }
    if(EnvUtils::IsOwnThreaded())
    	iSema.Signal();
    }
开发者ID:yeKcim,项目名称:warmux,代码行数:65,代码来源:sdlappsrv.cpp


示例11: draw_clock

/***************************************************************************
 *      draw_clock()
 * Draws a five-digit (-x:yy) clock in the center of the screen.
 *********************************************************************PROTO*/
void
draw_clock(int seconds)
{
    static int old_seconds = -111;	/* last time we drew */
    static SDL_Surface * digit[12];
    char buf[16];
    static int w = -1, h= -1; /* max digit width/height */
    int i, c;

    if (seconds == old_seconds || gametype == DEMO) return;

    if (old_seconds == -111) {
	/* setup code */

	for (i=0;i<10;i++) {
	    SPRINTF(buf,"%d",i);
	    digit[i] = TTF_RenderText_Blended(font,buf,color_blue);
	}
	SPRINTF(buf,":"); digit[10] = TTF_RenderText_Blended(font,buf,color_red);
	SPRINTF(buf,"-"); digit[11] = TTF_RenderText_Blended(font,buf,color_red);

	for (i=0;i<12;i++) {
	    Assert(digit[i]);
	    /* the colorkey and display format are already done */
	    /* find the largest dimensions */
	    if (digit[i]->w > w) w = digit[i]->w;
	    if (digit[i]->h > h) h = digit[i]->h;
	}
    }

    old_seconds = seconds;

    SPRINTF(buf,"%d:%02d",seconds / 60, seconds % 60);

    c = layout.time.x;
    layout.time.w = w * 5;
    layout.time.h = h;

    SDL_FillRect(widget_layer, &layout.time, int_solid_black); 

    if (strlen(buf) > 5)
	SPRINTF(buf,"----");

    if (strlen(buf) < 5)
	layout.time.x += ((5 - strlen(buf)) * w) / 2;


    for (i=0;buf[i];i++) {
	SDL_Surface * to_blit;

	if (buf[i] >= '0' && buf[i] <= '9')
	    to_blit = digit[buf[i] - '0'];
	else if (buf[i] == ':')
	    to_blit = digit[10];
	else if (buf[i] == '-')
	    to_blit = digit[11];
	else PANIC("unknown character in clock string [%s]",buf);

	/* center the letter horizontally */
	if (w > to_blit->w) layout.time.x += (w - to_blit->w) / 2;
	layout.time.w = to_blit->w;
	layout.time.h = to_blit->h;
	/*
	Debug("[%d+%d, %d+%d]\n",
		clockPos.x,clockPos.w,clockPos.y,clockPos.h);
		*/
	SDL_BlitSafe(to_blit, NULL, widget_layer, &layout.time);
	if (w > to_blit->w) layout.time.x -= (w - to_blit->w) / 2;
	layout.time.x += w;
    }

    layout.time.x = c;
    /*    clockPos.x = (screen->w - (w * 5)) / 2;*/
    layout.time.w = w * 5;
    layout.time.h = h;
    SDL_BlitSafe(flame_layer, &layout.time, screen, &layout.time);
    SDL_BlitSafe(widget_layer, &layout.time, screen, &layout.time);
    SDL_UpdateSafe(screen, 1, &layout.time);

    return;
}
开发者ID:usrshare,项目名称:atris,代码行数:85,代码来源:display.c


示例12: cond_wait_user

static int
cond_wait_user(struct pthread_cond *cvp, struct pthread_mutex *mp,
               const struct timespec *abstime, int cancel)
{
    struct pthread	*curthread = _get_curthread();
    struct sleepqueue *sq;
    int	recurse;
    int	error;
    int	defered;

    if (curthread->wchan != NULL)
        PANIC("thread was already on queue.");

    if (cancel)
        _thr_testcancel(curthread);

    _sleepq_lock(cvp);
    /*
     * set __has_user_waiters before unlocking mutex, this allows
     * us to check it without locking in pthread_cond_signal().
     */
    cvp->__has_user_waiters = 1;
    defered = 0;
    (void)_mutex_cv_unlock(mp, &recurse, &defered);
    curthread->mutex_obj = mp;
    _sleepq_add(cvp, curthread);
    for(;;) {
        _thr_clear_wake(curthread);
        _sleepq_unlock(cvp);
        if (defered) {
            defered = 0;
            if ((mp->m_lock.m_owner & UMUTEX_CONTESTED) == 0)
                (void)_umtx_op_err(&mp->m_lock, UMTX_OP_MUTEX_WAKE2,
                                   mp->m_lock.m_flags, 0, 0);
        }
        if (curthread->nwaiter_defer > 0) {
            _thr_wake_all(curthread->defer_waiters,
                          curthread->nwaiter_defer);
            curthread->nwaiter_defer = 0;
        }

        if (cancel) {
            _thr_cancel_enter2(curthread, 0);
            error = _thr_sleep(curthread, cvp->__clock_id, abstime);
            _thr_cancel_leave(curthread, 0);
        } else {
            error = _thr_sleep(curthread, cvp->__clock_id, abstime);
        }

        _sleepq_lock(cvp);
        if (curthread->wchan == NULL) {
            error = 0;
            break;
        } else if (cancel && SHOULD_CANCEL(curthread)) {
            sq = _sleepq_lookup(cvp);
            cvp->__has_user_waiters =
                _sleepq_remove(sq, curthread);
            _sleepq_unlock(cvp);
            curthread->mutex_obj = NULL;
            _mutex_cv_lock(mp, recurse);
            if (!THR_IN_CRITICAL(curthread))
                _pthread_exit(PTHREAD_CANCELED);
            else /* this should not happen */
                return (0);
        } else if (error == ETIMEDOUT) {
            sq = _sleepq_lookup(cvp);
            cvp->__has_user_waiters =
                _sleepq_remove(sq, curthread);
            break;
        }
    }
    _sleepq_unlock(cvp);
    curthread->mutex_obj = NULL;
    _mutex_cv_lock(mp, recurse);
    return (error);
}
开发者ID:sessaidi,项目名称:freebsd,代码行数:76,代码来源:thr_cond.c


示例13: _clientfb_read_cb

/*
 * Asynchronous I/O callback launched when framebuffer notifications are ready
 * to be read.
 * Param:
 *  opaque - ClientFramebuffer instance.
 */
static void
_clientfb_read_cb(void* opaque)
{
    ClientFramebuffer* fb_client = opaque;
    int  ret;

    // Read updates while they are immediately available.
    for (;;) {
        // Read next chunk of data.
        ret = read(fb_client->sock, fb_client->reader_buffer + fb_client->reader_offset,
                   fb_client->reader_bytes - fb_client->reader_offset);
        if (ret == 0) {
            /* disconnection ! */
            clientfb_destroy(fb_client);
            return;
        }
        if (ret < 0) {
            if (errno == EINTR) {
                /* loop on EINTR */
                continue;
            } else if (errno == EWOULDBLOCK || errno == EAGAIN) {
                // Chunk is not avalable at this point. Come back later.
                return;
            }
        }

        fb_client->reader_offset += ret;
        if (fb_client->reader_offset != fb_client->reader_bytes) {
            // There are still some data left in the pipe.
            continue;
        }

        // All expected data has been read. Time to change the state.
        if (fb_client->fb_state == WAIT_HEADER) {
            // Update header has been read. Prepare for the pixels.
            fb_client->fb_state = WAIT_PIXELS;
            fb_client->reader_offset = 0;
            fb_client->reader_bytes = fb_client->update_header.w *
                                      fb_client->update_header.h *
                                      (fb_client->bits_per_pixel / 8);
            fb_client->reader_buffer = malloc(fb_client->reader_bytes);
            if (fb_client->reader_buffer == NULL) {
                PANIC("Unable to allocate memory for framebuffer update\n");
            }
        } else {
            // Pixels have been read. Prepare for the header.
             uint8_t* pixels = fb_client->reader_buffer;

            fb_client->fb_state = WAIT_HEADER;
            fb_client->reader_offset = 0;
            fb_client->reader_bytes = sizeof(FBUpdateMessage);
            fb_client->reader_buffer = (uint8_t*)&fb_client->update_header;

            // Perform the update. Note that pixels buffer must be freed there.
            update_rect(fb_client->fb, fb_client->update_header.x,
                        fb_client->update_header.y, fb_client->update_header.w,
                        fb_client->update_header.h, fb_client->bits_per_pixel,
                        pixels);
        }
    }
}
开发者ID:phoenixdevs,项目名称:platform_external_qemu,代码行数:67,代码来源:framebuffer-ui.c


示例14: cluster_counter

void cluster_counter (int  no_of_things,  int *neighbors[], int * mask,
		     int cluster_count_per_size[], int * no_of_clusters,
		      int * max_size, int * secnd_max_size , int * clusters[]){
	

    /* arrays */ 
    static int*  * flag_ptr;          /* array of pointers to cluster flags*/
    static int   * flags;             /* array of available flags */
    static int   * bin  ;             /* for counting different clusters */
    /* counters, booleans etc */
    int flag_ctr, this_thing, other_thing; 
    int new_flag, cluster_count, isolated_count;
    int this_value, other_value, max_cluster, second_max;
    int color;
    
    /* for allocation purposes */
    static int first = 1;

    if ( first ) { /* do allocation */
	first = 0;
	/* flag ptrs   */
	flag_ptr     = calloc (no_of_things, sizeof(int*));
	/* flags        */
	flags        = calloc (no_of_things, sizeof(int));
	/* bins         */
	bin          = calloc (no_of_things, sizeof(int));
    }
    /* check if all alive: */ 
    if ( !( flag_ptr && flags && bin) ) {
	PANIC ("Error allocating memory in ClusterCounter."); 
    }

	
    /* set all the flags to 0 */
    memset (flags, 0, no_of_things*sizeof(int));
    /* the number of times new flag is assigned:*/
    new_flag = 0;
    /* set all the flag ptrs  to NULL */
    memset (flag_ptr, 0, no_of_things*sizeof(int*));
    /* color by cluster */ 
     
    for (this_thing=0; this_thing < no_of_things; this_thing++) {
	if (  mask [this_thing] ) {
	    for (other_thing=this_thing+1; other_thing < no_of_things; other_thing++) {
		if (  mask [other_thing] && neighbors[this_thing][other_thing]) {
		    if (flag_ptr[this_thing]){
			if (flag_ptr[other_thing]){ /*if both ptrs assigned*/
				/*************************************************/
				/* look at the flag values they are assigned to: */
			    if ( *flag_ptr[this_thing]  !=  *flag_ptr[other_thing] ) { 
				/* i.e. do something only if they differ*/
				this_value   = *flag_ptr[this_thing];
				other_value  = *flag_ptr[other_thing];
				for ( flag_ctr=0; flag_ctr < new_flag; flag_ctr++ ) {
				    if ( flags[flag_ctr] == other_value) {
					flags[flag_ctr] = this_value;
				    }
				}
				    
			    }
			} else {                       /* one not assigned*/ 
				/*************************************************/
			    flag_ptr[other_thing] = flag_ptr[this_thing];
			}
		    } else {
			if (flag_ptr[other_thing]){ /* one not assigned*/
				/*************************************************/
			    flag_ptr[this_thing]  = flag_ptr[other_thing];
			} else {                      /* both null*/
				/*************************************************/
			    /*  create new flag*/
			    flags[new_flag] = new_flag;
				/*  make both ptrs point there*/
			    flag_ptr[this_thing]  = flag_ptr[other_thing] = &flags[new_flag];
			    new_flag++;
			}
		    
		    }

		}
	    }
	}
    }

    /*count the clusters*/
    memset (bin, 0, no_of_things*sizeof(int));
    memset (clusters[0], 0, (no_of_things+1)*(no_of_things+1)*sizeof(int));
    cluster_count = 0;
    isolated_count = 0;
    for (this_thing=0; this_thing < no_of_things; this_thing++) {
	if (  mask [this_thing] ) {
	    if ( !flag_ptr[this_thing] ) {
		isolated_count++;
		clusters [0][0]++;
		clusters [0][ clusters [0][0] ] = this_thing;
	    } else {
		color = *flag_ptr[this_thing];
		if ( ! bin[color] ){
		    cluster_count ++;
		}
//.........这里部分代码省略.........
开发者ID:ivanamihalek,项目名称:c-utils,代码行数:101,代码来源:clustercounter.c


示例15: up_reprioritize_rtr

void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
{
  /* Verify that the caller is sane */

  if (tcb->task_state < FIRST_READY_TO_RUN_STATE ||
      tcb->task_state > LAST_READY_TO_RUN_STATE
#if SCHED_PRIORITY_MIN > 0
      || priority < SCHED_PRIORITY_MIN
#endif
#if SCHED_PRIORITY_MAX < UINT8_MAX
      || priority > SCHED_PRIORITY_MAX
#endif
    )
    {
       PANIC();
    }
  else
    {
      struct tcb_s *rtcb = this_task();
      bool switch_needed;

      sinfo("TCB=%p PRI=%d\n", tcb, priority);

      /* Remove the tcb task from the ready-to-run list.
       * sched_removereadytorun will return true if we just
       * remove the head of the ready to run list.
       */

      switch_needed = sched_removereadytorun(tcb);

      /* Setup up the new task priority */

      tcb->sched_priority = (uint8_t)priority;

      /* Return the task to the specified blocked task list.
       * sched_addreadytorun will return true if the task was
       * added to the new list.  We will need to perform a context
       * switch only if the EXCLUSIVE or of the two calls is non-zero
       * (i.e., one and only one the calls changes the head of the
       * ready-to-run list).
       */

      switch_needed ^= sched_addreadytorun(tcb);

      /* Now, perform the context switch if one is needed */

      if (switch_needed)
        {
          /* If we are going to do a context switch, then now is the right
           * time to add any pending tasks back into the ready-to-run list.
           * task list now
           */

          if (g_pendingtasks.head)
            {
              sched_mergepending();
            }

          /* Update scheduler parameters */

          sched_suspend_scheduler(rtcb);

         /* Are we in an interrupt handler? */

          if (g_current_regs)
            {
              /* Yes, then we have to do things differently.
               * Just copy the g_current_regs into the OLD rtcb.
               */

               up_savestate(rtcb->xcp.regs);

              /* Restore the exception context of the rtcb at the (new) head
               * of the ready-to-run task list.
               */

              rtcb = this_task();

              /* Update scheduler parameters */

              sched_resume_scheduler(rtcb);

              /* Then switch contexts.  Any necessary address environment
               * changes will be made when the interrupt returns.
               */

              up_restorestate(rtcb->xcp.regs);
            }

          /* No, then we will need to perform the user context switch */

          else
            {
              /* Switch context to the context of the task at the head of the
               * ready to run list.
               */

              struct tcb_s *nexttcb = this_task();

#ifdef CONFIG_ARCH_ADDRENV
//.........这里部分代码省略.........
开发者ID:a1ien,项目名称:nuttx,代码行数:101,代码来源:up_reprioritizertr.c


示例16: _thr_assert_lock_level

void
_thr_assert_lock_level()
{
	PANIC("locklevel <= 0");
}
开发者ID:coyizumi,项目名称:cs111,代码行数:5,代码来源:thr_kern.c


示例17: LpxAllocateConnection

VOID
LpxAllocateConnection(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_CONNECTION *TransportConnection
    )

/*++

Routine Description:

    This routine allocates storage for a transport connection. Some
    minimal initialization is done.

    NOTE: This routine is called with the device context spinlock
    held, or at such a time as synchronization is unnecessary.

Arguments:

    DeviceContext - the device context for this connection to be
        associated with.

    TransportConnection - Pointer to a place where this routine will
        return a pointer to a transport connection structure. Returns
        NULL if the storage cannot be allocated.

Return Value:

    None.

--*/

{

    PTP_CONNECTION Connection;

    if ((DeviceContext->MemoryLimit != 0) &&
            ((DeviceContext->MemoryUsage + sizeof(TP_CONNECTION)) >
                DeviceContext->MemoryLimit)) {
        PANIC("LPX: Could not allocate connection: limit\n");
        LpxWriteResourceErrorLog(
            DeviceContext,
            EVENT_TRANSPORT_RESOURCE_LIMIT,
            103,
            sizeof(TP_CONNECTION),
            CONNECTION_RESOURCE_ID);
        *TransportConnection = NULL;
        return;
    }

    Connection = (PTP_CONNECTION)ExAllocatePoolWithTag (
                                     NonPagedPool,
                                     sizeof (TP_CONNECTION),
                                     LPX_MEM_TAG_TP_CONNECTION);
    if (Connection == NULL) {
        PANIC("LPX: Could not allocate connection: no pool\n");
        LpxWriteResourceErrorLog(
            DeviceContext,
            EVENT_TRANSPORT_RESOURCE_POOL,
            203,
            sizeof(TP_CONNECTION),
            CONNECTION_RESOURCE_ID);
        *TransportConnection = NULL;
        return;
    }
    RtlZeroMemory (Connection, sizeof(TP_CONNECTION));

    IF_LPXDBG (LPX_DEBUG_DYNAMIC) {
        LpxPrint1 ("ExAllocatePool Connection %p\n", Connection);
    }

    DeviceContext->MemoryUsage += sizeof(TP_CONNECTION);
    ++DeviceContext->ConnectionAllocated;

    Connection->Type = LPX_CONNECTION_SIGNATURE;
    Connection->Size = sizeof (TP_CONNECTION);

    Connection->Provider = DeviceContext;
    Connection->ProviderInterlock = &DeviceContext->Interlock;
    KeInitializeSpinLock (&Connection->SpinLock);

    InitializeListHead (&Connection->LinkList);
    InitializeListHead (&Connection->AddressFileList);
    InitializeListHead (&Connection->AddressList);

    *TransportConnection = Connection;

}   /* LpxAllocateConnection */
开发者ID:Nevermore2015,项目名称:ndas4windows,代码行数:87,代码来源:connobj.c


示例18: up_syscall

void up_syscall(uint32_t *regs)
{
  lldbg("Syscall from 0x%x\n", regs[REG_PC]);
  current_regs = regs;
  PANIC();
}
开发者ID:KimMui,项目名称:i2sTest,代码行数:6,代码来源:up_syscall.c


示例19: up_block_task

void up_block_task(_TCB *tcb, tstate_t task_state)
{
  /* Verify that the context switch can be performed */

  if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) ||
      (tcb->task_state > LAST_READY_TO_RUN_STATE))
    {
      PANIC(OSERR_BADBLOCKSTATE);
    }
  else
    {
      _TCB *rtcb = (_TCB*)g_readytorun.head;
      bool switch_needed;

      /* Remove the tcb task from the ready-to-run list.  If we
       * are blocking the task at the head of the task list (the
       * m 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PANTHEIOS_LITERAL_STRING函数代码示例发布时间:2022-05-30
下一篇:
C++ PANGO_PIXELS函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap