示例#1
0
static void tt_link_thread_to_system(const char *name, TT_THREAD_T *thread)
{
	memcpy (thread->name, name, sizeof (thread->name));
	thread->name[sizeof (thread->name) - 1] = '\0';

	tt_disable_irq ();

#ifdef	TT_SUPPORT_MUTEX
	thread->priority	= thread->fixed_priority;
	listInit (&thread->list_wait_head);
	listInit (&thread->list_wait_node);
	thread->locked_by_mutex = false;
#endif	// TT_SUPPORT_MUTEX

	listInit (&thread->list_schedule);
	tt_set_thread_running (thread);

#ifdef	TT_SUPPORT_DUMP_THREAD
	listInit (&thread->list_threads);
	listMove (&g_all_threads, &thread->list_threads);
#endif	// TT_SUPPORT_STACK_CHECK


	tt_enable_irq ();
	
	//sysSafePrintf ("Create thread: %08x %s\n", thread, name);
}
示例#2
0
void tt_init (uint32_t systick_frequency)
{
	int i;

	tt_disable_irq ();
    
    tt_use_PSP((unsigned int)irq_stack + sizeof (irq_stack));
			
	listInit (&g_all_threads);
	for (i = 0; i < TT_THREAD_PRIORITY_NUM; i++)
		listInit (&g_athread_running[i]);
	g_athread_high_priorty = 0;
	
	g_thread_current = NULL;
	//tt_create_thread_nop ();
	tt_init_thread_main ();

	/* Enable timer to start schedule. */
	tt_timer_init (systick_frequency);

	tt_set_irq_priority ();
	
    tt_enable_irq ();
	
#if 0	/* Useless code! */	
	/* Call tt_thread_exit after main(). */
	atexit (tt_thread_exit);
#endif

#ifdef	TT_SUPPORT_USLEEP
	tt_enable_usleep ();
#endif	// TT_SUPPORT_USLEEP
}
示例#3
0
文件: battle.c 项目: phoboz/yz
BATTLE_ACTOR* create_battle_actor(
    BATTLE *battle,
    PLAYER *player
)
{
    BATTLE_ACTOR *ba;

    ba = (BATTLE_ACTOR *) malloc( sizeof(BATTLE_ACTOR) );
    if (ba == NULL) {

        fprintf(stderr, "Error - Out of memory\n");
        exit(1);

    }

    memset(ba, 0, sizeof(BATTLE_ACTOR));

    ba->type = ACTOR_HERO;
    ba->index = battle->counter++;
    ba->i = (player->x + player->h->w / 2) / BMARKER_WIDTH;
    ba->j = (player->y + player->h->h / 2) / BMARKER_HEIGHT;
    listInit(&ba->stepList);
    listInit(&ba->walkList);
    listInit(&ba->attackList);
    listInit(&ba->targetList);
    ba->cursor.i = ba->i;
    ba->cursor.j = ba->j;
    ba->player = player;
    player->x = ba->i * BMARKER_WIDTH;
    player->y = ba->j * BMARKER_HEIGHT;

    set_battle_state(battle, ba, BATTLE_STATE_IDLE, NULL);

    return ba;
}
示例#4
0
void CIOLIBCALL init_mouse(void)
{
	memset(&state,0,sizeof(state));
	state.click_timeout=0;
	state.multi_timeout=300;
	listInit(&state.input,LINK_LIST_SEMAPHORE|LINK_LIST_MUTEX);
	listInit(&state.output,LINK_LIST_SEMAPHORE|LINK_LIST_MUTEX);
	pthread_mutex_init(&unget_mutex, NULL);
	ciolib_mouse_initialized=1;
}
示例#5
0
// Add an new word to the global list
// wordStart is coming from the stack, so we must allocate a block 
// of memory to hold actual word here.
void addNewWord(char * wordStart, int length, size_t index) {
  wordInfo_t * wordInfo = NULL;
  char * word = NULL; 
  wordIndex_t * wordIndex;

  // Malloc a block of memory with size "wordInfo_t"
  wordInfo = (wordInfo_t *)malloc(sizeof(wordInfo_t));

  // We must allocate a new block of memory to hold actual word.
  // We can not point to wordStart since it is an local variable
  word = (char *)malloc(length+1);

  if(wordInfo == NULL || word == NULL) {
    fprintf(stderr, "Failed to allocate memory for wordInfo_t and word.\n");
    return;
  }

  // Initialize the word related information.
  memcpy(word, wordStart, length);
  word[length] = '\0';

  wordInfo->word = word;
  wordInfo->count = 1;
  wordInfo->dup = 0;
  listInit(&wordInfo->list);
  listInit(&wordInfo->indexlist);
  
  // Add this word into the global list.
  //fprintf(stderr, "Add new word: %s length %d. ADDING wordInfo %p\n", word, length,& wordInfo->list);
  listInsertTail(&wordInfo->list, &gWordsList);

  // Add corresponding index into the index list.
  wordIndex = (wordIndex_t *)malloc(sizeof(wordIndex_t));
  if(wordIndex  == NULL) {
    fprintf(stderr, "malloc failed for wordIndex\n");
    return;
  }

  wordIndex->index = index;
  //fprintf(stderr, "Adding wordIndex %p with index %ld\n", &wordIndex->list, index);
  listInit(&wordIndex->list);
  listInsertTail(&wordIndex->list, &wordInfo->indexlist);
  //listPrintItems(&gWordsList, 1);
  fprintf(stderr, "Adding wordIndex %p index %ld at %p\n", &wordIndex->list, wordIndex->index, &wordIndex->index);

  totalWords++;
  totalDiffWords++;
}
示例#6
0
static int
init_rules(const char *path)
{
	int rc = -1;
	FILE *fp;
	char line[LINE_SIZE];

	if ((fp = fopen(path, "r")) == NULL) {
		(void) fprintf(stderr, "%s: %s (%d)\n", path, strerror(errno), errno);
		goto error0;
	}

	pattern_path = path;
	listInit(&pattern_rules);

	while (fgets(line, sizeof (line), fp) != NULL) {
		/* Ignore all lines except those starting with a pattern. */
		if (*line == '/') {
			if (init_rule(line))
				goto error1;
		}
	}

	rc = 0;
error1:
	(void) fclose(fp);
error0:
	return rc;
}
示例#7
0
FUNCTION  void getFileLists(char *dirpath)
{
#ifdef PROC_TRACE
  traceFunc("== getFileLists(%s)\n", dirpath);
#endif /* PROC_TRACE */

  /*    listInit(&gl.sarchList, 0, "source-archives list & md5sum map"); */
  listInit(&cur.regfList, 0, "regular-files list");
  listInit(&cur.offList, 0, "buffer-offset list");
#ifdef FLAG_NO_COPYRIGHT
  listInit(&gl.nocpyrtList, 0, "no-copyright list");
#endif /* FLAG_NO_COPYRIGHT */

  listGetItem(&cur.regfList, cur.targetFile);
  return;
} /* getFileLists */
void aboutInit()
{
  char buf[128];
  list_t* txt;
  listItem* it;
  FILE* fp = android_fopen("data/about.txt", "r");

  if(!fp)
  {
	SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,  "Couldn't open data/about.txt");
    return;

  }
  txt = listInit(NULL);

  while( fgets(buf, 128, fp ) )
  {
    int l = strlen(buf);
    it = listAppendData(txt, malloc( l+1 ) );
    strcpy( (char*)(it->data), buf );
  }

  numLines = txt->count;
  lines = malloc( sizeof(char*)*numLines );
  listAddToArray((void*)lines,txt);
  listFree(txt);
}
示例#9
0
/* Available in: irq, thread. */
TT_MSG_QUEUE_T *tt_msg_queue_init (void *msg_buffer, size_t msg_buffer_size)
{
	TT_MSG_QUEUE_T *msg_queue;
	if (msg_buffer == NULL)
		return NULL;
	if (msg_buffer_size <= sizeof (TT_MSG_QUEUE_T))
		return NULL;

	msg_queue = (TT_MSG_QUEUE_T *) msg_buffer;
	msg_buffer = (void *)((char *) msg_buffer + sizeof (TT_MSG_QUEUE_T));
	msg_buffer_size -= sizeof (TT_MSG_QUEUE_T);
	
	msg_queue->msg_free = memInit (msg_buffer, msg_buffer_size, TT_MSG_T);
	if (msg_queue->msg_free == NULL)
		return NULL;
		
	msg_queue->max_msg_limit = listLength (msg_queue->msg_free);
	if (msg_queue->max_msg_limit <= 0)
		return NULL;
	
	msg_queue->msg_buffer = msg_buffer;
	msg_queue->msg_buffer_size = msg_buffer_size;
	listInit (&msg_queue->msg_used);
	tt_pc_init (&msg_queue->pc_semaphore, msg_queue->max_msg_limit);
	
	return msg_queue;
}
示例#10
0
int cgiInit()
{
    const char *str;

    if (init_called == true) {
        cgi_errno = CGIERR_REINIT;
        return false;
    }
    init_called = true;

    str = getenv("REQUEST_METHOD");
    if (str == NULL || (strcmp(str, "POST") && strcmp(str, "GET")))
    {
        cgi_errno = CGIERR_UREQM;
        return false;
    }

    listInit();
    if (!strcmp(str, "POST"))
        if(initPost()==false)
            return(false);

    if (!strcmp(str, "GET"))
        if(initGet()==false)
            return(false);

    init_complete = true;
    return ECGI_SUCCESS;
}
示例#11
0
int
hsm_init(void)
{
	struct itimerval 	hellotmr, selftmr;
	char fn[] = "hsm_init";

	NETDEBUG(MRSD, NETLOG_DEBUG2, ("%s: called \n", fn));

	/* DOWN State */
	hcp->nsm_list = listInit();

	/* Add an interval timer which wakes up and sends a hello message */
	memset(&hellotmr, 0, sizeof(hellotmr));
	hellotmr.it_interval.tv_sec = HELLO_INTERVAL;
	hcp->hellotid = timerAddToList(&hcp->Mtimer, &hellotmr, 0, \
		PSOS_TIMER_REL, "HelloTimer", SendHello, NULL);

	/* Add a timer which makes the host master if there is no response seen */
	memset(&selftmr, 0, sizeof(selftmr));
	selftmr.it_value.tv_sec = HELLO_INTERVAL*DEAD_FACTOR;
	hcp->selftid = timerAddToList(&hcp->Mtimer, &selftmr, 0, \
		PSOS_TIMER_REL, "SelfTimer", (TimerFn)HostIsLeader, NULL);

	return(1);
}
示例#12
0
List
CreateRecordList(HPktHdr *hpktp)
{
	List	reclist;
	int		i, numrecs;
	void	*item;

	reclist = listInit();

	if ( (hpktp->datalen)%sizeof(host_rec) != 0) {
		NETERROR(MRSD, ("Hello Pkt Corrupt\n"));
		return (NULL);
	}

	numrecs = (hpktp->datalen)/sizeof(host_rec);	

	for (i = 0; i < numrecs; i++) {
		item = Malloc(sizeof(host_rec));
		memcpy(item, (void *)((host_rec *)(hpktp+1) + i), sizeof(host_rec));
		if ( listAddItem(reclist, item) != 0) {
			NETERROR(MRSD, ("Error Adding Item to record list \n"));
			listDestroy(reclist);
			return (NULL);
		}
	}

	return (reclist);
}
示例#13
0
/*-----------------------------------------------------------------------------
    Name        : rmInitializeResearchStruct
    Description : initializes research structure for player
    Inputs      : Player
    Outputs     : none
    Return      : void
----------------------------------------------------------------------------*/
void rmInitializeResearchStruct(Player *player, bool candoresearch, sdword techlevel)
{
    sdword index;

    player->researchinfo.CanDoResearch = candoresearch;

    switch (techlevel)
    {
    case TECH_NOTECHNOLOGY  :
        player->researchinfo.HasTechnology = 0;
        break;
    case TECH_ALLTECHNOLOGY :
        player->researchinfo.HasTechnology = AllTechnology;
        break;
    }

    rmInitializeResearchStatics(player);

    for (index=0; index<NUM_RESEARCHLABS; index++)
    {
        player->researchinfo.researchlabs[index].labstatus = LS_NORESEARCHSHIP;
        player->researchinfo.researchlabs[index].topic     = NULL;
    }

    listInit(&player->researchinfo.listoftopics);
}
示例#14
0
void initCredits(SDL_Surface* screen)
{
  msgList=listInit(_freeCreditListItem);
  listAppendData(msgList, (void*)initMsg("Website","wizznic.org", screen));
  listAppendData(msgList, (void*)initMsg("Code/Gfx/Sfx","Jimmy Christensen", screen));
  listAppendData(msgList, (void*)initMsg("Gfx","ViperMD", screen));
  listAppendData(msgList, (void*)initMsg("Music","Sean Hawk", screen));

  listAppendData(msgList, (void*)initMsg("Thx","Qubodup", screen));
  listAppendData(msgList, (void*)initMsg("Thx","Farox", screen));
  listAppendData(msgList, (void*)initMsg("Thx","bMan", screen));
  listAppendData(msgList, (void*)initMsg("Thx","KML", screen));
  listAppendData(msgList, (void*)initMsg("Thx","Neil L", screen));
  listAppendData(msgList, (void*)initMsg("Thx","Zear", screen));
  listAppendData(msgList, (void*)initMsg("Thx","ReactorScram", screen));
  listAppendData(msgList, (void*)initMsg("Thx","torpor", screen));
  listAppendData(msgList, (void*)initMsg("Thx","klopsi", screen));

  listAppendData(msgList, (void*)initMsg("Greetings","GP32X.com", screen));
  listAppendData(msgList, (void*)initMsg("Greetings","freegamedev.net", screen));
  listAppendData(msgList, (void*)initMsg("Greetings","gcw-zero.com", screen));

  //Set current
  currentMsgIndex=0;
  setCurrent();
}
示例#15
0
int main(int argc, char *argv[])
{
 /**   simple_lls *head;
    head=(simple_lls *)malloc(sizeof(simple_lls));
    head->node.data=1;
    head->next=NULL;
    
    printf("head data = %d \n",head->node.data);
    free(head);**/
    
    List *list=(List *)malloc(sizeof(List));
    int data=1;
    int data2=2;
    int data3;
    listInit(list,&destroy);
    listInsertNext(list,NULL,(void *)&data);
    listInsertNext(list,NULL,(void *)&data2);
    listInsertNext(list,list->head->next,(void *)&data2);
    listRemoveNext(list,NULL,(void **)&data3);
    printf("list data = %d %d  \n",*(int *)list->head->data
    ,*(int *)list->head->next->data);
    listDestroy(list);
  
  system("PAUSE");	
  return 0;
}
示例#16
0
/* Available in: irq, thread. */
TT_BMSG_QUEUE_T *tt_bmsg_queue_init (void *msg_buffer, size_t msg_buffer_size, size_t each_msg_size)
{
	TT_BMSG_QUEUE_T *msg_queue;
	if (msg_buffer == NULL)
		return NULL;
	if (msg_buffer_size <= sizeof (TT_BMSG_QUEUE_T))
		return NULL;

	msg_queue = (TT_BMSG_QUEUE_T *) msg_buffer;
	msg_buffer = (void *)((char *) msg_buffer + sizeof (TT_BMSG_QUEUE_T));
	msg_buffer_size -= sizeof (TT_BMSG_QUEUE_T);
	each_msg_size = (each_msg_size + sizeof (int) - 1) / sizeof (int) * sizeof (int);
	
	msg_queue->queue.msg_free = __memInit (
		msg_buffer,
		msg_buffer_size,
		GetOffsetSize(TT_BMSG_T, msg_data) + each_msg_size,	
		(size_t) &((TT_BMSG_T *) 0)->list);
	if (msg_queue->queue.msg_free == NULL)
		return NULL;
		
	msg_queue->queue.max_msg_limit = listLength (msg_queue->queue.msg_free);
	if (msg_queue->queue.max_msg_limit <= 0)
		return NULL;
	
	msg_queue->queue.msg_buffer = msg_buffer;
	msg_queue->queue.msg_buffer_size = msg_buffer_size;
	listInit (&msg_queue->queue.msg_used);
	tt_pc_init (&msg_queue->queue.pc_semaphore, msg_queue->queue.max_msg_limit);
	
	msg_queue->each_msg_size = each_msg_size;
	return msg_queue;
}
示例#17
0
文件: about.c 项目: DusteDdk/Wizznic
void aboutInit()
{
  char buf[128];
  list_t* txt;
  listItem* it;
  FILE* fp = fopen( DATADIR"data/about.txt", "r");

  if(!fp)
  {
    printf("Couldn't open "DATADIR"data/about.txt\n");
       return;

  }
  txt = listInit(NULL);

  while( fgets(buf, 128, fp ) )
  {
    int l = strlen(buf);
    it = listAppendData(txt, malloc( l+1 ) );
    strcpy( (char*)(it->data), buf );
  }

  numLines = txt->count;
  lines = malloc( sizeof(char*)*numLines );
  listAddToArray((void*)lines,txt);
  listFree(txt);
}
/*******************************************************************************
**
** Function         phNxpNciHal_init_monitor
**
** Description      Initialize the semaphore monitor
**
** Returns          Pointer to monitor, otherwise NULL if failed
**
*******************************************************************************/
phNxpNciHal_Monitor_t*
phNxpNciHal_init_monitor(void)
{
    NXPLOG_NCIHAL_D("Entering phNxpNciHal_init_monitor");

    if (nxpncihal_monitor == NULL)
    {
        nxpncihal_monitor = (phNxpNciHal_Monitor_t *) malloc(
                sizeof(phNxpNciHal_Monitor_t));
    }

    if (nxpncihal_monitor != NULL)
    {
        memset(nxpncihal_monitor, 0x00, sizeof(phNxpNciHal_Monitor_t));

        if (pthread_mutex_init(&nxpncihal_monitor->reentrance_mutex, NULL)
                == -1)
        {
            NXPLOG_NCIHAL_E("reentrance_mutex creation returned 0x%08x", errno);
            goto clean_and_return;
        }

        if (pthread_mutex_init(&nxpncihal_monitor->concurrency_mutex, NULL)
                == -1)
        {
            NXPLOG_NCIHAL_E("concurrency_mutex creation returned 0x%08x", errno);
            pthread_mutex_destroy(&nxpncihal_monitor->reentrance_mutex);
            goto clean_and_return;
        }

        if (listInit(&nxpncihal_monitor->sem_list) != 1)
        {
            NXPLOG_NCIHAL_E("Semaphore List creation failed");
            pthread_mutex_destroy(&nxpncihal_monitor->concurrency_mutex);
            pthread_mutex_destroy(&nxpncihal_monitor->reentrance_mutex);
            goto clean_and_return;
        }
    }
    else
    {
        NXPLOG_NCIHAL_E("nxphal_monitor creation failed");
        goto clean_and_return;
    }

    NXPLOG_NCIHAL_D("Returning with SUCCESS");

    return nxpncihal_monitor;

clean_and_return:
    NXPLOG_NCIHAL_D("Returning with FAILURE");

    if (nxpncihal_monitor != NULL)
    {
        free(nxpncihal_monitor);
        nxpncihal_monitor = NULL;
    }

    return NULL;
}
示例#19
0
文件: battle.c 项目: phoboz/yz
BATTLE_ACTOR* new_battle_actor(
    BATTLE *battle,
    int i,
    int j,
    ACTOR *actor,
    ACTOR_TYPE type
)
{
    BATTLE_ACTOR *ba;

    ba = (BATTLE_ACTOR *) malloc( sizeof(BATTLE_ACTOR) );
    if (ba == NULL) {

        fprintf(stderr, "Error - Out of memory\n");
        exit(1);

    }

    memset(ba, 0, sizeof(BATTLE_ACTOR));

    ba->type = type;
    ba->index = battle->counter++;
    ba->i = i;
    ba->j = j;
    listInit(&ba->stepList);
    listInit(&ba->walkList);
    listInit(&ba->attackList);
    listInit(&ba->targetList);
    ba->cursor.i = i;
    ba->cursor.j = j;
    ba->player = new_player(i * BMARKER_WIDTH, j * BMARKER_HEIGHT, actor);

    if ((ba->player->spells[0] = load_spell_XML("fire.stat")) == NULL) {
        fprintf(stderr, "ERROR - Unable to load spell.\n");
        exit(1);
    }

    if ((ba->player->spells[1] = load_spell_XML("heal.stat")) == NULL) {
        fprintf(stderr, "ERROR - Unable to load spell.\n");
        exit(1);
    }

    set_battle_state(battle, ba, BATTLE_STATE_IDLE, NULL);

    return ba;
}
void DefenseFighterInit(Ship *ship)
{
    DefenseFighterSpec *spec = (DefenseFighterSpec *)ship->ShipSpecifics;
    DefenseFighterStatics *defensefighterstatics;
    defensefighterstatics = (DefenseFighterStatics *) ((ShipStaticInfo *)(ship->staticinfo))->custstatinfo;
    spec->DefenseFighterCanNowRotate = TRUE;
    listInit(&spec->DefenseList);
}
示例#21
0
文件: map.c 项目: AndrewBelt/bored
void mapInit() {
	map.size = (Vector){256, 256};
	map.tiles = calloc(map.size.x * map.size.y, sizeof(Tile));
	listInit(&map.minions);
	
	map.offset = (Vector){SIDEBAR_WIDTH, 0};
	map.zoom = 2;
}
示例#22
0
int testaudio_init(void)
{
	bufTestAudioInitMemoryPool ();
	
	listInit (&g_testaudio.listAudio);
	tt_pc_init (&g_testaudio.pcAudio, bufTestAudioGetTotalBlocksNum ());
	
	return 0;
}
示例#23
0
void horseRaceInit()
{
    udword i;
    horseGetNumBars(&horseBarInfo);

    //initialize current bar to the 0th bar
    localbar=0;

    for(i=0;i<MAX_MULTIPLAYER_PLAYERS;i++)
    {
        horseracestatus.barnum[i] = 0;
        horseracestatus.percent[i] = 0;
        horseracestatus.hrstatusstr[i][0] = 0;
        if (autodownloadmapRequired())
            TTimerStart(&hrPlayerDropoutTimers[i],HorseRacePlayerDropoutTime*2.0f);     // give double time for autodownloads
        else
            TTimerStart(&hrPlayerDropoutTimers[i],HorseRacePlayerDropoutTime);
        PlayersAlreadyDrawnDropped[i] = FALSE;
    }

    for (i=0;i<NUM_CHAT_LINES;i++)
    {
        chathistory[i].message[0] = 0;
    }

    listInit(&horseCrapRegion.cutouts);

    JustInit = TRUE;

    if (!hrScreensHandle)
    {
        feCallbackAddMultiple(hrCallBack);
        feDrawCallbackAddMultiple(hrDrawCallback);
        hrScreensHandle = feScreensLoad(HR_FIBFile);
    }

    if (!ShouldHaveMousePtr) mouseCursorHide();

    if (singlePlayerGame)
    {
        hrBaseRegion = feScreenStart(&horseCrapRegion, HR_SingleRaceScreen);
    }
    else
    {
        hrBaseRegion = feScreenStart(&horseCrapRegion, (multiPlayerGame) ? HR_RaceScreen : HR_RaceScreenNotNetwork);
    }

    playernamefont = frFontRegister(HR_PlayerNameFont);

    hrRunning=TRUE;
    if (RGLtype == SWtype && feShouldSaveMouseCursor())
    {
        rglFeature(RGL_SAVEBUFFER_ON);
    }
    hrBackgroundDirty = (RGLtype == SWtype) ? 10000 : 3;
    hrBackgroundReinit = FALSE;
}
示例#24
0
文件: session.c 项目: mwt5175/ndbg
dbgSession* DbgSessionNew (char* command, pid_t pid, tid_t tid, handle_t process, handle_t thread) {
	dbgSession* session = (dbgSession*) malloc (sizeof (dbgSession));   
	if (!session)
		return 0;
	session->process.name = command;
	session->process.id.pid = pid;
	session->process.id.tid = tid;
	session->process.process = process;
	session->process.thread = thread;
	session->state = DBG_STATE_CONTINUE;
	session->proc = 0;
	listInit (&session->process.libraryList);
	listInit (&session->process.threadList);
	listInit (&session->process.sourceFileList);
	listInit (&session->process.breakPointList);
	listInit (&session->process.watchPointList);
	return session;
}
示例#25
0
文件: list.c 项目: Vifon/linked-list
List listCopy(List source)
{
    List copy = listInit();
    while ((source = listNext(source)))
    {
        listPushBack(copy, source->v);
    }
    return copy;
}
示例#26
0
文件: ial.c 项目: fkolacek/FIT-VUT
void stInit(SYMBOL_TABLE_PTR st){
	if(!st)
		return;
	
	BT_Init(&st->start.symbols);
	BT_Init(&st->functions);
	
	listInit(&st->start.staticValues);
	listInit(&st->start.instructions);
	
	st->start.calledCount = 0;
	st->start.argumentsCount = 0;
	st->start.argumentsCalled = 0;
	
	st->curr = &(st->start);
	
	stInitLibFunctions(st);
}
示例#27
0
/*-----------------------------------------------------------------------------
    Name        : pingStartup
    Description : Startup the ping module
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void pingStartup(void)
{
    scriptSet(NULL, "ping.script", pingTweaks);
    pingAnomalyMinScreenSize = primScreenToGLScaleX(pingAnomalyMinScreenSize);
    pingNewShipMinScreenSize = primScreenToGLScaleX(pingNewShipMinScreenSize);
    pingBattleMinScreenSize = primScreenToGLScaleX(pingBattleMinScreenSize);
    pingTaskHandle = taskStart(pingUpdateTask, PNG_TaskPeriod, 0);
    listInit(&pingList);
    pingReset();
}
示例#28
0
文件: vp_jpeg.c 项目: LucidOne/Rovio
void vjpegInit(void)
{
#ifndef ECOS
    tt_rmutex_init(&g_vpJPEG.mtLock);
    tt_rmutex_init(&g_vpJPEG.mtLockEncoder);
    tt_rmutex_init(&g_vpJPEG.mtLockDecoder);
    
    tt_sem_init(&g_vpJPEG.semEncoder, 1);
    tt_sem_init(&g_vpJPEG.semDecoder, 1);
	tt_sem_down(&g_vpJPEG.semEncoder);
	tt_sem_down(&g_vpJPEG.semDecoder);
#else
    cyg_mutex_init(&g_vpJPEG.mtLock);
    cyg_mutex_init(&g_vpJPEG.mtLockEncoder);
    cyg_mutex_init(&g_vpJPEG.mtLockDecoder);
    
    cyg_semaphore_init(&g_vpJPEG.semEncoder, 1);
    cyg_semaphore_init(&g_vpJPEG.semDecoder, 1);
	cyg_semaphore_wait(&g_vpJPEG.semEncoder);
	cyg_semaphore_wait(&g_vpJPEG.semDecoder);
#endif
    
    g_vpJPEG.nRefCount = 0;
    g_vpJPEG.nRefCount_Encoder = 0;
    g_vpJPEG.nRefCount_Decoder = 0;
        
    g_vpJPEG.pJPEGEncodeBuffer = NULL;
    
   	listInit (&g_vpJPEG.listEncodedJPEG);
   	
   	g_vpJPEG.nJPEGQua = 2;
   	g_vpJPEG.bOnTheFly = TRUE;
   	g_vpJPEG.nOnTheFlyCount = 0;

#ifndef ECOS
    sysInstallISR(IRQ_LEVEL_1, IRQ_JPEG, (void*)jpegIntHandler);
#else
	cyg_interrupt_disable();
	cyg_interrupt_create(IRQ_JPEG, IRQ_LEVEL_1, NULL, &jpegIntHandler, &jpegIntHandler_DSR,
				&(g_vpJPEG.cygIntrHandle), &(g_vpJPEG.cygIntrBuffer));
	cyg_interrupt_attach(g_vpJPEG.cygIntrHandle);
	cyg_interrupt_unmask(IRQ_JPEG);
	cyg_interrupt_enable();
#endif

    jpegSetIRQHandler(C_JPEG_CALLBACK_ENCODE_COMPLETE_INTERRUPT, vjpegEncoderCom_Callback);
    jpegSetIRQHandler(C_JPEG_CALLBACK_DECODE_COMPLETE_INTERRUPT, vjpegDecoderCom_Callback);
    jpegSetIRQHandler(C_JPEG_CALLBACK_DECODE_ERROR_INTERRUPT, vjpegDecoderErr_Callback);
	if(g_vpJPEG.bOnTheFly == TRUE)
	{
		jpegSetIRQHandler(C_JPEG_CALLBACK_ENCODE_SWONTHEFLY_WAIT_INTERRUPT, vjpegOnTheFlyCom_Callback);
	}
		
    bJPEGInit = TRUE;
}
int main(void) {
  unsigned ind;
  listInit();
  for (ind = 0; ind < MAX; ind++)
    listInsert(rand() % (MAX*2), ind);
  printf("Списъкът съдържа следните елементи: \n"); listPrint();
  printf("\nТестване:\n");
  performSearchTest();
  printf("Списъкът след търсенето: \n"); listPrint();
  return 0;
}
示例#30
0
msg_queue_t* DLLCALL msgQueueInit(msg_queue_t* q, long flags)
{
	if(q==NULL) {
		if((q=(msg_queue_t*)malloc(sizeof(msg_queue_t)))==NULL)
			return(NULL);
		flags |= MSG_QUEUE_MALLOC;
	} 

	memset(q,0,sizeof(msg_queue_t));

	q->flags = flags;
	q->refs = 1;
	q->owner_thread_id = pthread_self();

	if(q->flags&MSG_QUEUE_BIDIR)
		listInit(&q->in,LINK_LIST_SEMAPHORE);
	listInit(&q->out,LINK_LIST_SEMAPHORE);

	return(q);
}