コード例 #1
0
ファイル: MyHero.cpp プロジェクト: lcglcglcg/mygame
void MyHero::select(int index)
{
    
    if (index == 0) {
        
        frame_init("hero/minren1.ExportJson", "minren1");
        hero_index = index;
        attack_time = 0.4;
        skill_time = 2.0;
        
    } else if (index == 1) {
        
        frame_init("hero/NewProject.ExportJson", "NewProject");
        hero_index = index;
        attack_time = 0.4;
        skill_time = 1.8;
        
    } else if (index == 2) {
        
        frame_init("hero/xiaoyin.ExportJson", "xiaoyin");
        hero_index = index;
        attack_time = 0.4;
        skill_time = 1.4;
    }
}
コード例 #2
0
ファイル: compile.c プロジェクト: Albermg7/boost
LIST *
compile_rule(
    PARSE   *parse,
    FRAME *frame )
{
    FRAME       inner[1];
    LIST    *result;
    PARSE   *p;
    

    /* Build up the list of arg lists */

    frame_init( inner );
    inner->prev = frame;
    inner->prev_user = frame->module->user_module ? frame : frame->prev_user;
    inner->module = frame->module; /* This gets fixed up in evaluate_rule(), below */
    inner->procedure = parse;

    for( p = parse->left; p; p = p->left )
        lol_add( inner->args, parse_evaluate( p->right, frame ) );

    /* And invoke rule */

    result = evaluate_rule( parse->string, inner );

    frame_free( inner );

    return result;
}
コード例 #3
0
ファイル: search.c プロジェクト: Kirija/XPIR
void call_bind_rule( OBJECT * target_, OBJECT * boundname_ )
{
    LIST * const bind_rule = var_get( root_module(), constant_BINDRULE );
    if ( !list_empty( bind_rule ) )
    {
        OBJECT * target = object_copy( target_ );
        OBJECT * boundname = object_copy( boundname_ );
        if ( boundname && target )
        {
            /* Prepare the argument list. */
            FRAME frame[ 1 ];
            frame_init( frame );

            /* First argument is the target name. */
            lol_add( frame->args, list_new( target ) );

            lol_add( frame->args, list_new( boundname ) );
            if ( lol_get( frame->args, 1 ) )
            {
                OBJECT * rulename = list_front( bind_rule );
                list_free( evaluate_rule( bindrule( rulename, root_module() ), rulename, frame ) );
            }

            /* Clean up */
            frame_free( frame );
        }
        else
        {
            if ( boundname )
                object_free( boundname );
            if ( target )
                object_free( target );
        }
    }
}
コード例 #4
0
ファイル: make1.c プロジェクト: Albermg7/boost
/* Look up the __TIMING_RULE__ variable on the given target, and if
 * non-empty, invoke the rule it names, passing the given
 * timing_info
 */
static void call_timing_rule(TARGET* target, timing_info* time)
{
    LIST* timing_rule;
    
    pushsettings(target->settings);
    timing_rule = var_get( "__TIMING_RULE__" );
    popsettings(target->settings);

    if (timing_rule)
    {
        /* We'll prepend $(__TIMING_RULE__[2-]) to the first argument */
        LIST* initial_args = list_copy( L0, timing_rule->next );
            
        /* Prepare the argument list */
        FRAME frame[1];
        frame_init( frame );

        /* First argument is the name of the timed target */
        lol_add( frame->args, list_new( initial_args, target->name ) );
        append_double_string(frame->args, time->user);
        append_double_string(frame->args, time->system);

        if( lol_get( frame->args, 2 ) )
            evaluate_rule( timing_rule->string, frame );
            
        /* Clean up */
        frame_free( frame );
    }
}
コード例 #5
0
ファイル: compile.c プロジェクト: 4ukuta/core
LIST * call_rule( char * rulename, FRAME * caller_frame, ... )
{
    va_list va;
    LIST * result;

    FRAME       inner[1];
    frame_init( inner );
    inner->prev = caller_frame;
    inner->prev_user = caller_frame->module->user_module ?
        caller_frame : caller_frame->prev_user;
    inner->module = caller_frame->module;
    inner->procedure = 0;

    va_start( va, caller_frame );
    for ( ; ; )
    {
        LIST * l = va_arg( va, LIST* );
        if ( !l )
            break;
        lol_add( inner->args, l );
    }
    va_end( va );

    result = evaluate_rule( rulename, inner );

    frame_free( inner );

    return result;
}
コード例 #6
0
ファイル: compile.c プロジェクト: 4ukuta/core
LIST * compile_rule( PARSE * parse, FRAME * frame )
{
    FRAME   inner[ 1 ];
    LIST  * result;
    PARSE * p;

    /* Build up the list of arg lists. */
    frame_init( inner );
    inner->prev = frame;
    inner->prev_user = frame->module->user_module ? frame : frame->prev_user;
    inner->module = frame->module;  /* This gets fixed up in evaluate_rule(), below. */
    inner->procedure = parse;
    /* Special-case LOL of length 1 where the first list is totally empty.
       This is created when calling functions with no parameters, due to
       the way jam grammar is written. This is OK when one jam function
       calls another, but really not good when Jam function calls Python.  */
    if ( parse->left->left == NULL && parse->left->right->func == compile_null)
        ;
    else
        for ( p = parse->left; p; p = p->left )
            lol_add( inner->args, parse_evaluate( p->right, frame ) );

    /* And invoke the rule. */
    result = evaluate_rule( parse->string, inner );
    frame_free( inner );
    return result;
}
コード例 #7
0
ファイル: command.c プロジェクト: Kirija/XPIR
CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell )
{
    CMD * cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) );
    FRAME frame[ 1 ];

    assert( cmd );
    cmd->rule = rule;
    cmd->shell = shell;
    cmd->next = 0;
    cmd->noop = 0;

    lol_init( &cmd->args );
    lol_add( &cmd->args, targets );
    lol_add( &cmd->args, sources );
    string_new( cmd->buf );

    frame_init( frame );
    frame->module = rule->module;
    lol_init( frame->args );
    lol_add( frame->args, list_copy( targets ) );
    lol_add( frame->args, list_copy( sources ) );
    function_run_actions( rule->actions->command, frame, stack_global(),
        cmd->buf );
    frame_free( frame );

    return cmd;
}
コード例 #8
0
ファイル: make1.c プロジェクト: AlexMioMio/boost
static void call_action_rule
(
    TARGET * target,
    int status,
    timing_info const * time,
    char const * executed_command,
    char const * command_output
)
{
    LIST * action_rule;

    pushsettings( root_module(), target->settings );
    action_rule = var_get( root_module(), constant_ACTION_RULE );
    popsettings( root_module(), target->settings );

    if ( !list_empty( action_rule ) )
    {
        /* rule action-rule (
            args * :
            target :
            command status start end user system :
            output ? ) */

        /* Prepare the argument list. */
        FRAME frame[ 1 ];
        OBJECT * rulename = list_front( action_rule );
        frame_init( frame );

        /* args * :: $(__ACTION_RULE__[2-]) */
        lol_add( frame->args, list_copy_range( action_rule, list_next(
            list_begin( action_rule ) ), list_end( action_rule ) ) );

        /* target :: the name of the target */
        lol_add( frame->args, list_new( object_copy( target->name ) ) );

        /* command status start end user system :: info about the action command
         */
        lol_add( frame->args,
            list_push_back( list_push_back( list_push_back( list_push_back( list_push_back( list_new(
                object_new( executed_command ) ),
                outf_int( status ) ),
                outf_time( &time->start ) ),
                outf_time( &time->end ) ),
                outf_double( time->user ) ),
                outf_double( time->system ) ) );

        /* output ? :: the output of the action command */
        if ( command_output )
            lol_add( frame->args, list_new( object_new( command_output ) ) );
        else
            lol_add( frame->args, L0 );

        /* Call the rule. */
        evaluate_rule( bindrule( rulename, root_module() ), rulename, frame );

        /* Clean up. */
        frame_free( frame );
    }
}
コード例 #9
0
ファイル: mem_man.c プロジェクト: asweeney86/Composite
static inline void
mm_init(void)
{
	static int first = 1;
	if (unlikely(first)) {
		first = 0;
		frame_init();
	}
}
コード例 #10
0
void prepare_eval (control_par *cpar, int *n_fix) {
    int     i_img, i, filenumber, step_shake, count = 0;
	double  dummy;
    sequence_par *seq_par;
    FILE *fpp;
    
    int part_pointer; /* Holds index of particle later */
    
    frame frm;
    frame_init(&frm, cpar->num_cams, MAX_TARGETS);
    
	seq_par = read_sequence_par("parameters/sequence.par", cpar->num_cams);

	fpp = fopen ("parameters/dumbbell.par", "r");
    if (fpp){
        fscanf (fpp, "%lf", &dummy);
		fscanf (fpp, "%lf", &dummy);
	    fscanf (fpp, "%lf", &dummy);
	    fscanf (fpp, "%lf", &dummy);
		fscanf (fpp, "%d", &step_shake);
        fclose (fpp);
    }

    for (filenumber = seq_par->first; filenumber <= seq_par->last; \
        filenumber += step_shake)
    {
        read_frame(&frm, "res/db_is", NULL, NULL, seq_par->img_base_name,
            filenumber);

		for (i = 0; i < frm.num_parts; i++) {
            for (i_img = 0; i_img < cpar->num_cams; i_img++) {
                part_pointer = frm.correspond[i].p[i_img];
                if (part_pointer != CORRES_NONE) {
                    pix[i_img][count].x = frm.targets[i_img][part_pointer].x;
                    pix[i_img][count].y = frm.targets[i_img][part_pointer].y;
                } else {
                    pix[i_img][count].x = -999;
                    pix[i_img][count].y = -999;
                }
                
				if(pix[i_img][count].x>-999 && pix[i_img][count].y>-999){
				   pixel_to_metric (&crd[i_img][count].x, &crd[i_img][count].y,
                       pix[i_img][count].x, pix[i_img][count].y, cpar);
				}
				else{
                   crd[i_img][count].x=-1e10;
				   crd[i_img][count].y=-1e10;
				}
				crd[i_img][count].pnr=count;
			}
			count ++;
		}
	}
    free_frame(&frm);
	nfix=count;
}
コード例 #11
0
ファイル: headers.c プロジェクト: 0xDEC0DE8/mcsema
void
headers( TARGET * t )
{
    LIST   * hdrscan;
    LIST   * hdrrule;
	#ifndef OPT_HEADER_CACHE_EXT
    LIST   * headlist = L0;
	#endif
    regexp * re[ MAXINC ];
    int rec = 0;
    LISTITER iter, end;

    hdrscan = var_get( root_module(), constant_HDRSCAN );
    if ( list_empty( hdrscan ) )
        return;

    hdrrule = var_get( root_module(), constant_HDRRULE );
    if ( list_empty( hdrrule ) )
        return;

    if ( DEBUG_HEADER )
        printf( "header scan %s\n", object_str( t->name ) );

    /* Compile all regular expressions in HDRSCAN */
    iter = list_begin( hdrscan ), end = list_end( hdrscan );
    for ( ; ( rec < MAXINC ) && iter != end; iter = list_next( iter ) )
    {
        re[ rec++ ] = regex_compile( list_item( iter ) );
    }

    /* Doctor up call to HDRRULE rule */
    /* Call headers1() to get LIST of included files. */
    {
        FRAME   frame[1];
        frame_init( frame );
        lol_add( frame->args, list_new( object_copy( t->name ) ) );
#ifdef OPT_HEADER_CACHE_EXT
        lol_add( frame->args, hcache( t, rec, re, hdrscan ) );
#else
        lol_add( frame->args, headers1( headlist, t->boundname, rec, re ) );
#endif

        if ( lol_get( frame->args, 1 ) )
        {
            /* The third argument to HDRRULE is the bound name of
             * $(<) */
            lol_add( frame->args, list_new( object_copy( t->boundname ) ) );

            list_free( evaluate_rule( list_front( hdrrule ), frame ) );
        }

        /* Clean up. */
        frame_free( frame );
    }
}
コード例 #12
0
ファイル: compile.c プロジェクト: 4ukuta/core
static void type_check
(
    char  * type_name,
    LIST  * values,
    FRAME * caller,
    RULE  * called,
    LIST  * arg_name
)
{
    static module_t * typecheck = 0;

    /* If nothing to check, bail now. */
    if ( !values || !type_name )
        return;

    if ( !typecheck )
        typecheck = bindmodule( ".typecheck" );

    /* If the checking rule can not be found, also bail. */
    {
        RULE checker_, *checker = &checker_;

        checker->name = type_name;
        if ( !typecheck->rules || !hashcheck( typecheck->rules, (HASHDATA * *)&checker ) )
            return;
    }

    exit_module( caller->module );

    while ( values != 0 )
    {
        LIST *error;
        FRAME frame[1];
        frame_init( frame );
        frame->module = typecheck;
        frame->prev = caller;
        frame->prev_user = caller->module->user_module ? caller : caller->prev_user;

        enter_module( typecheck );
        /* Prepare the argument list */
        lol_add( frame->args, list_new( L0, values->string ) );
        error = evaluate_rule( type_name, frame );

        exit_module( typecheck );

        if ( error )
            argument_error( error->string, called, caller, arg_name );

        frame_free( frame );
        values = values->next;
    }

    enter_module( caller->module );
}
コード例 #13
0
ファイル: frame_test.c プロジェクト: HalosGhost/tty-solitaire
void test_frame_init() {
  struct frame *frame;

  frame_malloc(&frame);
  frame_init(frame);

  assert(frame->window == NULL);
  assert(frame->begin_y == 0);
  assert(frame->begin_x == 0);

  frame_free(frame);
}
コード例 #14
0
ファイル: make1.c プロジェクト: DieselPowerKOR/quakeslash
/* Look up the __ACTION_RULE__ variable on the given target, and if
 * non-empty, invoke the rule it names, passing the given info, 
 * timing_info, executed command and command output
 */
static void call_action_rule(TARGET* target, int status, timing_info* time,
    char *executed_command, char *command_output)
{
    LIST* action_rule;

    pushsettings(target->settings);
    action_rule = var_get( "__ACTION_RULE__" );
    popsettings(target->settings);

    if (action_rule)
    {
        /* rule action-rule (
            args * :
            target :
            command status start end user system :
            output ? ) */

        /* Prepare the argument list */
        FRAME frame[1];
        frame_init( frame );

        /* args * :: $(__ACTION_RULE__[2-]) */
        lol_add( frame->args, list_copy( L0, action_rule->next ) );

        /* target :: the name of the target */
        lol_add( frame->args, list_new( L0, target->name ) );

        /* command status start end user system :: info about the action command */
        lol_add( frame->args,
            list_new( list_new( list_new( list_new( list_new( list_new( L0,
                newstr(executed_command) ),
                outf_int(status) ),
                outf_time(time->start) ),
                outf_time(time->end) ),
                outf_double(time->user) ),
                outf_double(time->system) ) );

        /* output ? :: the output of the action command */
        if (command_output)
            lol_add(frame->args, list_new(L0, newstr(command_output)));
        else
            lol_add(frame->args, L0);

        /* Call the rule. */
        evaluate_rule( action_rule->string, frame );

        /* Clean up */
        frame_free( frame );
    }
}
コード例 #15
0
ファイル: headers.c プロジェクト: KerwinMa/AerothFlyffSource
void
headers( TARGET *t )
{
    LIST	*hdrscan;
    LIST	*hdrrule;
    LIST	*headlist = 0;
    regexp	*re[ MAXINC ];
    int	rec = 0;
        
    if( !( hdrscan = var_get( "HDRSCAN" ) ) || 
        !( hdrrule = var_get( "HDRRULE" ) ) )
        return;

    if( DEBUG_HEADER )
        printf( "header scan %s\n", t->name );

    /* Compile all regular expressions in HDRSCAN */

    while( rec < MAXINC && hdrscan )
    {
        re[rec++] = regex_compile( hdrscan->string );
        hdrscan = list_next( hdrscan );
    }

    /* Doctor up call to HDRRULE rule */
    /* Call headers1() to get LIST of included files. */
    {
        FRAME	frame[1];
        frame_init( frame );
        lol_add( frame->args, list_new( L0, t->name ) );
#ifdef OPT_HEADER_CACHE_EXT
        lol_add( frame->args, hcache( t, rec, re, hdrscan ) );
#else
        lol_add( frame->args, headers1( headlist, t->boundname, rec, re ) );
#endif

        if( lol_get( frame->args, 1 ) )
        {
            /* The third argument to HDRRULE is the bound name of
             * $(<) */
            lol_add( frame->args, list_new( L0, t->boundname ) );

            list_free( evaluate_rule( hdrrule->string, frame ) );
        }

        /* Clean up */

        frame_free( frame );
    }
}
コード例 #16
0
ファイル: frame_test.c プロジェクト: HalosGhost/tty-solitaire
void test_frame_set() {
  struct frame *frame;
  int begin_y = 5;
  int begin_x = 10;

  frame_malloc(&frame);
  frame_init(frame);
  frame_set(frame, begin_y, begin_x);

  assert(frame->begin_y == begin_y);
  assert(frame->begin_x == begin_x);

  frame_free(frame);
}
コード例 #17
0
/**
 * @fn void main(void)
 * @brief main process
 * @param none
 * @return none
 */
void main(void) {
	TRISC5 = 0;
	TRISB7 = 0;
	TRISB6 = 0;
	RC5 = 0;
	RB7 = 0;
	RB6 = 0;
	uint16_t ui16_blink = 0;
	int8_t i8_ret = -1;

	// initialise uart
	//~ uart_init();

	// initialise Fifo	
	fifo_init();

	// initialisation
	interrupt_init();

	// initialise I2C HW
	i2c_init();

	// initialise lcd HW
	frame_init();
	
	//~ uart_printf("LCD 2x16 CONTROLLER TEST\n\0");
	
	while(1) {
		// test if frames are in the buffer
		if(gui8_token != 0) {
			i8_ret = frame_decode_fifo(); // decode frame and execute actions
			gui8_token --; // decrease number of frames in the buffer
		}
		/* else nothing to do */
		
		if(ui16_blink == 65000) {
			if(RC5 == 1) {
				RC5 = 0;
			}
			else {
				RC5 = 1;
			}
			ui16_blink = 0;
		}
		else {
			ui16_blink ++;
		}
	}
}
コード例 #18
0
ファイル: mem_test.c プロジェクト: xluoly/raw-os_sqlite
void test_slab(void * pParam)
{
	void *test_mem1;
	int count = 0;
	int i = 0;
	int ret = 0;
	
	frame_init((RAW_U32)test_page_mem, 48*1024);
	slab_cache_init();
	/*Decide whether the magazine work.*/
	slab_enable_cpucache();
	/*0--on, for user program debugging purpose; 
	  1--off, normally, it should be off.*/
	free_check_switch = 0;


	for(i = 0; i < 20; i++){	
		test_mem1 = raw_slab_malloc(1024);
		test_mem1 = raw_slab_malloc(1024);
		
		if (test_mem1) {
			vc_port_printf("test_mem1 is %p\n", test_mem1);
			ret = raw_slab_free(test_mem1);
			if(ret != 0)
				vc_port_printf("****raw_slab_free failed!\n");
			count++;
		}
		else {
			RAW_ASSERT(0);
		}
	}

	/*free a freed address*/
	if(free_check_switch == 0){
		ret = raw_slab_free(test_mem1);
		if(ret != 0)
			vc_port_printf("****Error: Free a freed obj!\n");
	}

	/*Some debug information*/
	slab_print_list();
	vc_port_printf("\n");
	zone_print_one(0);
	while (1);
}
コード例 #19
0
ファイル: mem_man.c プロジェクト: nks5295/Composite
static inline void
mm_init(void)
{
	printc("core %ld: mm init as thread %d\n", cos_cpuid(), cos_get_thd_id());

	/* Expanding VAS. */
	printc("mm expanding %lu MBs @ %p\n", (NREGIONS-1) * round_up_to_pgd_page(1) / 1024 / 1024, 
	       (void *)round_up_to_pgd_page((unsigned long)&cos_comp_info.cos_poly[1]));
	if (cos_vas_cntl(COS_VAS_SPD_EXPAND, cos_spd_id(), 
			 round_up_to_pgd_page((unsigned long)&cos_comp_info.cos_poly[1]), 
			 (NREGIONS-1) * round_up_to_pgd_page(1))) {
		printc("MM could not expand VAS\n");
		BUG();
	}

	frame_init();
	printc("core %ld: mm init done\n", cos_cpuid());
}
コード例 #20
0
/* Initializes the page allocator.  At most USER_PAGE_LIMIT
   pages are put into the user pool. */
void
palloc_init (size_t user_page_limit)
{
  /* Free memory starts at 1 MB and runs to the end of RAM. */
  uint8_t *free_start = ptov (1024 * 1024);
  uint8_t *free_end = ptov (init_ram_pages * PGSIZE);
  size_t free_pages = (free_end - free_start) / PGSIZE;
  size_t user_pages = free_pages / 2;
  size_t kernel_pages;
  if (user_pages > user_page_limit)
    user_pages = user_page_limit;
  kernel_pages = free_pages - user_pages;

  /* Give half of memory to kernel, half to user. */
  init_pool (&kernel_pool, free_start, kernel_pages, "kernel pool");
  init_pool (&user_pool, free_start + kernel_pages * PGSIZE,
             user_pages, "user pool");
  frame_init (user_pages);
}
コード例 #21
0
ファイル: main.c プロジェクト: gapry/AOS
static void _sos_init(seL4_CPtr* ipc_ep, seL4_CPtr* async_ep){
    seL4_Word dma_addr;
    seL4_Word low, high;
    int err;

    /* Retrieve boot info from seL4 */
    _boot_info = seL4_GetBootInfo();
    conditional_panic(!_boot_info, "Failed to retrieve boot info\n");
    if(verbose > 0){
        print_bootinfo(_boot_info);
    }

    /* Initialise the untyped sub system and reserve memory for DMA */
    err = ut_table_init(_boot_info);
    conditional_panic(err, "Failed to initialise Untyped Table\n");
    /* DMA uses a large amount of memory that will never be freed */
    dma_addr = ut_steal_mem(DMA_SIZE_BITS);
    conditional_panic(dma_addr == 0, "Failed to reserve DMA memory\n");

    /* find available memory */
    ut_find_memory(&low, &high);

    /* Initialise the untyped memory allocator */
    ut_allocator_init(low, high);

    /* Initialise the cspace manager */
    err = cspace_root_task_bootstrap(ut_alloc, ut_free, ut_translate,
                                     malloc, free);
    conditional_panic(err, "Failed to initialise the c space\n");

    /* Initialise DMA memory */
    err = dma_init(dma_addr, DMA_SIZE_BITS);
    conditional_panic(err, "Failed to intiialise DMA memory\n");

    /* Initialise IPC */
    _sos_ipc_init(ipc_ep, async_ep);

    /* Initialise frame table */
    err = frame_init();
    conditional_panic(err, "Failed to initialise frame table\n");
}
コード例 #22
0
ファイル: make1.c プロジェクト: DieselPowerKOR/quakeslash
/* Look up the __TIMING_RULE__ variable on the given target, and if
 * non-empty, invoke the rule it names, passing the given
 * timing_info
 */
static void call_timing_rule(TARGET* target, timing_info* time)
{
    LIST* timing_rule;
    
    pushsettings(target->settings);
    timing_rule = var_get( "__TIMING_RULE__" );
    popsettings(target->settings);

    if (timing_rule)
    {
        /* rule timing-rule (
            args * :
            target :
            start end user system ) */

        /* Prepare the argument list */
        FRAME frame[1];
        frame_init( frame );

        /* args * :: $(__TIMING_RULE__[2-]) */
        lol_add( frame->args, list_copy( L0, timing_rule->next ) );

        /* target :: the name of the target */
        lol_add( frame->args, list_new( L0, target->name ) );

        /* start end user system :: info about the action command */
        lol_add( frame->args,
            list_new( list_new( list_new( list_new( L0,
                outf_time(time->start) ),
                outf_time(time->end) ),
                outf_double(time->user) ),
                outf_double(time->system) ) );

        /* Call the rule. */
        evaluate_rule( timing_rule->string, frame );

        /* Clean up */
        frame_free( frame );
    }
}
コード例 #23
0
ファイル: search.c プロジェクト: DieselPowerKOR/quakeslash
void call_bind_rule(
    char* target_,
    char* boundname_ )
{
    LIST* bind_rule = var_get( "BINDRULE" );
    if( bind_rule )
    {
        /* No guarantee that target is an allocated string, so be on the
         * safe side */
        char* target = copystr( target_ );
        
        /* Likewise, don't rely on implementation details of newstr.c: allocate
         * a copy of boundname */
        char* boundname = copystr( boundname_ );
        if( boundname && target )
        {
            /* Prepare the argument list */
            FRAME frame[1];
            frame_init( frame );
                    
            /* First argument is the target name */
            lol_add( frame->args, list_new( L0, target ) );
                    
            lol_add( frame->args, list_new( L0, boundname ) );
            if( lol_get( frame->args, 1 ) )
                evaluate_rule( bind_rule->string, frame );
            
            /* Clean up */
            frame_free( frame );
        }
        else
        {
            if( boundname )
                freestr( boundname );
            if( target )
                freestr( target );
        }
    }
}
コード例 #24
0
void call_bind_rule
(
    OBJECT * target_,
    OBJECT * boundname_
)
{
    OBJECT * varname = object_new( "BINDRULE" );
    LIST * bind_rule = var_get( varname );
    object_free( varname );
    if ( bind_rule )
    {
        OBJECT * target = object_copy( target_ );
        OBJECT * boundname = object_copy( boundname_ );
        if ( boundname && target )
        {
            /* Prepare the argument list. */
            FRAME frame[1];
            frame_init( frame );

            /* First argument is the target name. */
            lol_add( frame->args, list_new( L0, target ) );

            lol_add( frame->args, list_new( L0, boundname ) );
            if ( lol_get( frame->args, 1 ) )
                list_free( evaluate_rule( bind_rule->value, frame ) );

            /* Clean up */
            frame_free( frame );
        }
        else
        {
            if ( boundname )
                object_free( boundname );
            if ( target )
                object_free( target );
        }
    }
}
コード例 #25
0
ファイル: frame.c プロジェクト: jyin0813/OpenBSD-src
static fde *
find_fde (void *pc)
{
  struct object *ob;
  size_t lo, hi;

  init_object_mutex_once ();
  __gthread_mutex_lock (&object_mutex);

  for (ob = objects; ob; ob = ob->next)
    {
      if (ob->pc_begin == 0)
	frame_init (ob);
      if (pc >= ob->pc_begin && pc < ob->pc_end)
	break;
    }

  __gthread_mutex_unlock (&object_mutex);

  if (ob == 0)
    return 0;

  /* Standard binary search algorithm.  */
  for (lo = 0, hi = ob->count; lo < hi; )
    {
      size_t i = (lo + hi) / 2;
      fde *f = ob->fde_array[i];

      if (pc < f->pc_begin)
	hi = i;
      else if (pc >= f->pc_begin + f->pc_range)
	lo = i + 1;
      else
	return f;
    }

  return 0;
}
コード例 #26
0
ファイル: make1.c プロジェクト: AlexMioMio/boost
static void call_timing_rule( TARGET * target, timing_info const * const time )
{
    LIST * timing_rule;

    pushsettings( root_module(), target->settings );
    timing_rule = var_get( root_module(), constant_TIMING_RULE );
    popsettings( root_module(), target->settings );

    if ( !list_empty( timing_rule ) )
    {
        /* rule timing-rule ( args * : target : start end user system ) */

        /* Prepare the argument list. */
        FRAME frame[ 1 ];
        OBJECT * rulename = list_front( timing_rule );
        frame_init( frame );

        /* args * :: $(__TIMING_RULE__[2-]) */
        lol_add( frame->args, list_copy_range( timing_rule, list_next(
            list_begin( timing_rule ) ), list_end( timing_rule ) ) );

        /* target :: the name of the target */
        lol_add( frame->args, list_new( object_copy( target->name ) ) );

        /* start end user system :: info about the action command */
        lol_add( frame->args, list_push_back( list_push_back( list_push_back( list_new(
            outf_time( &time->start ) ),
            outf_time( &time->end ) ),
            outf_double( time->user ) ),
            outf_double( time->system ) ) );

        /* Call the rule. */
        evaluate_rule( bindrule( rulename , root_module() ), rulename, frame );

        /* Clean up. */
        frame_free( frame );
    }
}
コード例 #27
0
ファイル: card.c プロジェクト: HalosGhost/tty-solitaire
void card_init(struct card *card) {
  frame_init(card->frame);
  card->value = NO_VALUE;
  card->suit = NO_SUIT;
  card->face = NO_FACE;
}
コード例 #28
0
ファイル: main_m0.c プロジェクト: bebtio/pixy-dev
int main(void)
{
	//CTIMER_DECLARE();
#if 0
	uint32_t memory = SRAM1_LOC;
	uint32_t lut = SRAM1_LOC;

	//while(1);
	memset((void *)QQ_LOC, 0x01, 0x3000);
	g_qqueue->writeIndex = 0;
	g_qqueue->produced = 0;
	g_qqueue->consumed = 0;

 	while(1)
 		getRLSFrame(&memory, &lut); 
#endif
#if 0
	int i = 0x12345678;
	foo(&i);
	printf("%d\n", i);
	while(1);
#endif
#if 0
	int i;
	uint32_t lut = SRAM1_LOC;
 	uint32_t memory = SRAM1_LOC+0x1000;
	uint8_t *plut = (uint8_t *)lut;
	for (i=0; i<0x4000; i++)
		plut[i] = i%5==0 ? 1 : 0;
	
 	while(1)
 		getRLSFrame(&memory, &lut); 

#endif
#if 1
	_DBG("M0 start\n");

	chirpOpen();
	exec_init();
	frame_init();
	rls_init();

#if 0
	while(1)
	{
		if (g_foo)
			loop0();
	}
#endif

#if 0
	vsync();
#endif
#if 0
	//while(g_loop);
	uint8_t type = CAM_GRAB_M1R2;
	uint32_t memory = SRAM1_LOC;
	uint16_t offset = 0;
	uint16_t width = 320;
	uint16_t height = 200;
	while(1)
	{
		 getFrame(&type, &memory, &offset, &offset, &width, &height);
		 i++;

		 if (i%50==0)
		 {
			 _DBD32(i), _CR();
		 }
	}
#endif
	//printf("M0 ready\n");
	exec_loop();
#endif
#if 0
	while(1)
	{
		CTIMER_START();
		syncM1((uint32_t *)&LPC_GPIO_PORT->PIN[1], 0x2000);
		CTIMER_STOP();
		
		printf("%d\n", CTIMER_GET());
	}	
#endif
#if 0
{
	uint32_t i;
	uint8_t *lut = (uint8_t *)SRAM1_LOC + 0x10000;
	uint32_t memory = SRAM1_LOC;
	uint32_t size = SRAM1_SIZE/2;
	for (i=0; i<0x10000; i++)
		lut[i] = 0;
	lut[0xb400] = 0;
	lut[0xb401] = 1;
	lut[0xb402] = 1;
	lut[0xb403] = 1;
	lut[0xb404] = 0;
	lut[0xb405] = 1;
	lut[0xb406] = 1;
	lut[0xb407] = 0;
	lut[0xb408] = 0;
	lut[0xb409] = 0;

	while(1)
 		getRLSFrame(&memory, &size); //, (uint32_t *)&lut);
}
#endif

return 0;
}
コード例 #29
0
ファイル: about.c プロジェクト: ofilin/remcam2
INT_PTR CALLBACK about_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	int temp;
	int x, y, w, h;
	context *cx;
	PAINTSTRUCT ps;
	HDC hdc;

	switch(msg)
	{
	case WM_INITDIALOG:

		SetWindowLongPtr(hwnd, DWL_USER, 0);

		//set window pos
		w = GetSystemMetrics(SM_CXDLGFRAME) * 2 +
			WIDTH;

		h = GetSystemMetrics(SM_CYDLGFRAME) * 2 +
			GetSystemMetrics(SM_CYCAPTION) +
			HEIGHT;

		x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
		y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;

		SetWindowPos(hwnd, NULL, x, y, w, h, SWP_NOZORDER);

		//init cx
		temp = bmpsize(WIDTH, HEIGHT);

		if( (!(cx = malloc(sizeof(context)))) ||
			(!(cx->buffer = malloc(temp))) ||
			(!(cx->frame = malloc(temp))) )
		{
			DestroyWindow(hwnd);
			return 1;
		}

		cx->framelength = temp;

		cx->hdc = GetDC(hwnd);

		SetWindowLongPtr(hwnd, DWL_USER, (LONG_PTR)cx);

		//generate first frame
		frame_init(cx);

		//set frame move timer
		SetTimer(hwnd, TIMER, INTERVAL, 0);

		return 1;

	case WM_PAINT:
		if((cx = (void*)GetWindowLong(hwnd, DWL_USER)))
		{
			if((hdc = BeginPaint(hwnd, &ps)))
			{
				imageput(hdc, 0, 0, WIDTH, HEIGHT, cx->frame);
				EndPaint(hwnd, &ps);
			}
		}
		return 1;

	case WM_TIMER:
		switch(wp)
		{
		case TIMER:
			if((cx = (void*)GetWindowLong(hwnd, DWL_USER)))
			{
				framemove(cx);
				imageput(cx->hdc, 0, 0, WIDTH, HEIGHT, cx->frame);
			}
			return 1;
		}
		break;

	case WM_DESTROY:
		if((cx = (void*)GetWindowLong(hwnd, DWL_USER)))
		{
			KillTimer(hwnd, TIMER);
			ReleaseDC(hwnd, cx->hdc);
			free(cx->buffer);
			free(cx->frame);
			free(cx);
		}
		return 1;

	case WM_CLOSE:
		EndDialog(hwnd, 0);
		return 1;
	}
	return 0;
}
コード例 #30
0
ファイル: jam.c プロジェクト: nishiken/boost-svn
int main( int argc, char * * argv, char * * arg_environ )
{
    int                     n;
    char                  * s;
    struct bjam_option      optv[N_OPTS];
    char            const * all = "all";
    int                     status;
    int                     arg_c = argc;
    char          *       * arg_v = argv;
    char            const * progname = argv[0];
    module_t              * environ_module;

#if defined(unix) || defined(__unix)
    sigset_t sigmask;
    struct sigaction sa;

    sigemptyset(&sigmask);
    sigaddset(&sigmask, SIGCHLD);
    sigprocmask(SIG_BLOCK, &sigmask, NULL);
    sa.sa_flags = 0;
    sa.sa_handler = child_sig_handler;
    sigemptyset(&sa.sa_mask);
    sigaction(SIGCHLD, &sa, NULL);
    sigemptyset(&empty_sigmask);
#endif

    saved_argv0 = argv[0];

    BJAM_MEM_INIT();

# ifdef OS_MAC
    InitGraf(&qd.thePort);
# endif

    --argc;
    ++argv;

    if ( getoptions( argc, argv, "-:l:m:d:j:p:f:gs:t:ano:qv", optv ) < 0 )
    {
        printf( "\nusage: %s [ options ] targets...\n\n", progname );

        printf( "-a      Build all targets, even if they are current.\n" );
        printf( "-dx     Set the debug level to x (0-9).\n" );
        printf( "-fx     Read x instead of Jambase.\n" );
        /* printf( "-g      Build from newest sources first.\n" ); */
        printf( "-jx     Run up to x shell commands concurrently.\n" );
        printf( "-lx     Limit actions to x number of seconds after which they are stopped.\n" );
        printf( "-mx     Limit action output buffer to x kb's of data, after which action output is read and ignored.\n" );
        printf( "-n      Don't actually execute the updating actions.\n" );
        printf( "-ox     Write the updating actions to file x.\n" );
        printf( "-px     x=0, pipes action stdout and stderr merged into action output.\n" );
        printf( "-q      Quit quickly as soon as a target fails.\n" );
        printf( "-sx=y   Set variable x=y, overriding environment.\n" );
        printf( "-tx     Rebuild x, even if it is up-to-date.\n" );
        printf( "-v      Print the version of jam and exit.\n" );
        printf( "--x     Option is ignored.\n\n" );

        exit( EXITBAD );
    }

    /* Version info. */
    if ( ( s = getoptval( optv, 'v', 0 ) ) )
    {
        printf( "Boost.Jam  " );
        printf( "Version %s. %s.\n", VERSION, OSMINOR );
        printf( "   Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.  \n" );
        printf( "   Copyright 2001 David Turner.\n" );
        printf( "   Copyright 2001-2004 David Abrahams.\n" );
        printf( "   Copyright 2002-2008 Rene Rivera.\n" );
        printf( "   Copyright 2003-2008 Vladimir Prus.\n" );

        return EXITOK;
    }

    /* Pick up interesting options. */
    if ( ( s = getoptval( optv, 'n', 0 ) ) )
        globs.noexec++, globs.debug[2] = 1;

    if ( ( s = getoptval( optv, 'p', 0 ) ) )
    {
        /* Undocumented -p3 (acts like both -p1 -p2) means separate pipe action
         * stdout and stderr.
         */
        globs.pipe_action = atoi( s );
        if ( ( 3 < globs.pipe_action ) || ( globs.pipe_action < 0 ) )
        {
            printf(
                "Invalid pipe descriptor '%d', valid values are -p[0..3].\n",
                globs.pipe_action );
            exit( EXITBAD );
        }
    }

    if ( ( s = getoptval( optv, 'q', 0 ) ) )
        globs.quitquick = 1;

    if ( ( s = getoptval( optv, 'a', 0 ) ) )
        anyhow++;

    if ( ( s = getoptval( optv, 'j', 0 ) ) )
    {
        globs.jobs = atoi( s );
        if (globs.jobs == 0)
        {
            printf("Invalid value for the '-j' option.\n");
            exit(EXITBAD);
        }
    }

    if ( ( s = getoptval( optv, 'g', 0 ) ) )
        globs.newestfirst = 1;

    if ( ( s = getoptval( optv, 'l', 0 ) ) )
        globs.timeout = atoi( s );

    if ( ( s = getoptval( optv, 'm', 0 ) ) )
        globs.maxbuf = atoi( s ) * 1024;

    /* Turn on/off debugging */
    for ( n = 0; ( s = getoptval( optv, 'd', n ) ); ++n )
    {
        int i;

        /* First -d, turn off defaults. */
        if ( !n )
            for ( i = 0; i < DEBUG_MAX; ++i )
                globs.debug[i] = 0;

        i = atoi( s );

        if ( ( i < 0 ) || ( i >= DEBUG_MAX ) )
        {
            printf( "Invalid debug level '%s'.\n", s );
            continue;
        }

        /* n turns on levels 1-n. */
        /* +n turns on level n. */
        if ( *s == '+' )
            globs.debug[i] = 1;
        else while ( i )
            globs.debug[i--] = 1;
    }

    constants_init();

    {
        PROFILE_ENTER( MAIN );

#ifdef HAVE_PYTHON
        {
            PROFILE_ENTER( MAIN_PYTHON );
            Py_Initialize();
            {
                static PyMethodDef BjamMethods[] = {
                    {"call", bjam_call, METH_VARARGS,
                     "Call the specified bjam rule."},
                    {"import_rule", bjam_import_rule, METH_VARARGS,
                     "Imports Python callable to bjam."},
                    {"define_action", bjam_define_action, METH_VARARGS,
                     "Defines a command line action."},
                    {"variable", bjam_variable, METH_VARARGS,
                     "Obtains a variable from bjam's global module."},
                    {"backtrace", bjam_backtrace, METH_VARARGS,
                     "Returns bjam backtrace from the last call into Python."},
                    {"caller", bjam_caller, METH_VARARGS,
                     "Returns the module from which the last call into Python is made."},
                    {NULL, NULL, 0, NULL}
                };

                Py_InitModule( "bjam", BjamMethods );
            }
            PROFILE_EXIT( MAIN_PYTHON );
        }
#endif

#ifndef NDEBUG
        run_unit_tests();
#endif
#if YYDEBUG != 0
        if ( DEBUG_PARSE )
            yydebug = 1;
#endif

        /* Set JAMDATE. */
        var_set( root_module(), constant_JAMDATE, list_new( L0, outf_time(time(0)) ), VAR_SET );

        /* Set JAM_VERSION. */
        var_set( root_module(), constant_JAM_VERSION,
                 list_new( list_new( list_new( L0,
                   object_new( VERSION_MAJOR_SYM ) ),
                   object_new( VERSION_MINOR_SYM ) ),
                   object_new( VERSION_PATCH_SYM ) ),
                   VAR_SET );

        /* Set JAMUNAME. */
#if defined(unix) || defined(__unix)
        {
            struct utsname u;

            if ( uname( &u ) >= 0 )
            {
                var_set( root_module(), constant_JAMUNAME,
                         list_new(
                             list_new(
                                 list_new(
                                     list_new(
                                         list_new( L0,
                                            object_new( u.sysname ) ),
                                         object_new( u.nodename ) ),
                                     object_new( u.release ) ),
                                 object_new( u.version ) ),
                             object_new( u.machine ) ), VAR_SET );
            }
        }
#endif /* unix */

        /* Load up environment variables. */

        /* First into the global module, with splitting, for backward
         * compatibility.
         */
        var_defines( root_module(), use_environ, 1 );

        environ_module = bindmodule( constant_ENVIRON );
        /* Then into .ENVIRON, without splitting. */
        var_defines( environ_module, use_environ, 0 );

        /*
         * Jam defined variables OS & OSPLAT. We load them after environment, so
         * that setting OS in environment does not change Jam's notion of the
         * current platform.
         */
        var_defines( root_module(), othersyms, 1 );

        /* Load up variables set on command line. */
        for ( n = 0; ( s = getoptval( optv, 's', n ) ); ++n )
        {
            char *symv[2];
            symv[ 0 ] = s;
            symv[ 1 ] = 0;
            var_defines( root_module(), symv, 1 );
            var_defines( environ_module, symv, 0 );
        }

        /* Set the ARGV to reflect the complete list of arguments of invocation.
         */
        for ( n = 0; n < arg_c; ++n )
        {
            var_set( root_module(), constant_ARGV, list_new( L0, object_new( arg_v[n] ) ), VAR_APPEND );
        }

        /* Initialize built-in rules. */
        load_builtins();

        /* Add the targets in the command line to the update list. */
        for ( n = 1; n < arg_c; ++n )
        {
            if ( arg_v[ n ][ 0 ] == '-' )
            {
                char * f = "-:l:d:j:f:gs:t:ano:qv";
                for ( ; *f; ++f ) if ( *f == arg_v[ n ][ 1 ] ) break;
                if ( ( f[ 1 ] == ':' ) && ( arg_v[ n ][ 2 ] == '\0' ) ) ++n;
            }
            else
            {
                OBJECT * target = object_new( arg_v[ n ] );
                mark_target_for_updating( target );
                object_free( target );
            }
        }

        if (!targets_to_update())
        {
            mark_target_for_updating( constant_all );
        }

        /* Parse ruleset. */
        {
            FRAME frame[ 1 ];
            frame_init( frame );
            for ( n = 0; ( s = getoptval( optv, 'f', n ) ); ++n )
            {
                OBJECT * filename = object_new( s );
                parse_file( filename, frame );
                object_free( filename );
            }

            if ( !n )
            {
                parse_file( constant_plus, frame );
            }
        }

        status = yyanyerrors();

        /* Manually touch -t targets. */
        for ( n = 0; ( s = getoptval( optv, 't', n ) ); ++n )
        {
            OBJECT * target = object_new( s );
            touch_target( target );
            object_free( target );
        }

        /* If an output file is specified, set globs.cmdout to that. */
        if ( ( s = getoptval( optv, 'o', 0 ) ) )
        {
            if ( !( globs.cmdout = fopen( s, "w" ) ) )
            {
                printf( "Failed to write to '%s'\n", s );
                exit( EXITBAD );
            }
            ++globs.noexec;
        }

        /* The build system may set the PARALLELISM variable to override -j
           options.  */
        {
            LIST *p = L0;
            p = var_get ( root_module(), constant_PARALLELISM );
            if ( p )
            {
                int j = atoi( object_str( p->value ) );
                if ( j == -1 )
                {
                    printf( "Invalid value of PARALLELISM: %s\n", object_str( p->value ) );
                }
                else
                {
                    globs.jobs = j;
                }
            }
        }

        /* KEEP_GOING overrides -q option. */
        {
            LIST *p = L0;
            p = var_get( root_module(), constant_KEEP_GOING );
            if ( p )
            {
                int v = atoi( object_str( p->value ) );
                if ( v == 0 )
                    globs.quitquick = 1;
                else
                    globs.quitquick = 0;
            }
        }

        /* Now make target. */
        {
            PROFILE_ENTER( MAIN_MAKE );

            LIST * targets = targets_to_update();
            if (targets)
            {
                int targets_count = list_length( targets );
                OBJECT * * targets2 = (OBJECT * *)
                    BJAM_MALLOC( targets_count * sizeof( OBJECT * ) );
                int n = 0;
                for ( ; targets; targets = list_next( targets ) )
                    targets2[ n++ ] = targets->value;
                status |= make( targets_count, targets2, anyhow );
                BJAM_FREE( (void *)targets2 );
            }
            else
            {
                status = last_update_now_status;
            }

            PROFILE_EXIT( MAIN_MAKE );
        }

        PROFILE_EXIT( MAIN );
    }

    if ( DEBUG_PROFILE )
        profile_dump();

    
#ifdef OPT_HEADER_CACHE_EXT
    hcache_done();
#endif

    clear_targets_to_update();

    /* Widely scattered cleanup. */
    file_done();
    rules_done();
    stamps_done();
    search_done();
    class_done();
    modules_done();
    regex_done();
    exec_done();
    pwd_done();
    path_done();
    function_done();
    list_done();
    constants_done();
    object_done();

    /* Close cmdout. */
    if ( globs.cmdout )
        fclose( globs.cmdout );

#ifdef HAVE_PYTHON
    Py_Finalize();
#endif

    BJAM_MEM_CLOSE();

    return status ? EXITBAD : EXITOK;
}