Ejemplo n.º 1
0
void lib_ring_buffer_backend_reset(struct lib_ring_buffer_backend *bufb)
{
	struct channel_backend *chanb = &bufb->chan->backend;
	const struct lib_ring_buffer_config *config = &chanb->config;
	unsigned long num_subbuf_alloc;
	unsigned int i;

	num_subbuf_alloc = chanb->num_subbuf;
	if (chanb->extra_reader_sb)
		num_subbuf_alloc++;

	for (i = 0; i < chanb->num_subbuf; i++)
		bufb->buf_wsb[i].id = subbuffer_id(config, 0, 1, i);
	if (chanb->extra_reader_sb)
		bufb->buf_rsb.id = subbuffer_id(config, 0, 1,
						num_subbuf_alloc - 1);
	else
		bufb->buf_rsb.id = subbuffer_id(config, 0, 1, 0);

	for (i = 0; i < num_subbuf_alloc; i++) {
		/* Don't reset mmap_offset */
		v_set(config, &bufb->array[i]->records_commit, 0);
		v_set(config, &bufb->array[i]->records_unread, 0);
		bufb->array[i]->data_size = 0;
		/* Don't reset backend page and virt addresses */
	}
	/* Don't reset num_pages_per_subbuf, cpu, allocated */
	v_set(config, &bufb->records_read, 0);
}
Ejemplo n.º 2
0
void idle(void) {
	static int frames;
	static float time;
	float ifps;
	vec3 v;
	vec4 q0,q1,q2;
	matrix m;

	ifps = 1.0 / getfps();
	
	if(!my_pause) angle += ifps * 360.0 / 4.0;
	
	v_set(sin(angle * DEG2RAD / 3),cos(angle * DEG2RAD / 7),2,light);
	
	v_set(0,0,1,v);
	q_set(v,psi,q0);
	v_set(0,1,0,v);
	q_set(v,phi,q1);
	q_multiply(q0,q1,q2);
	q_to_matrix(q2,m);
	v_set(dist,0,0,camera);
	v_transform(camera,m,camera);
	v_add(camera,mesh,camera);
	
	frames++;
	time += ifps;

	if(time > 1.0) {
		printf("%d frames %.2f fps\n",frames,(float)frames / time);
		frames = 0;
		time = 0;
	}
}
Ejemplo n.º 3
0
void lib_ring_buffer_backend_reset(struct lttng_ust_lib_ring_buffer_backend *bufb,
				   struct lttng_ust_shm_handle *handle)
{
	struct channel_backend *chanb;
	const struct lttng_ust_lib_ring_buffer_config *config;
	unsigned long num_subbuf_alloc;
	unsigned int i;

	chanb = &shmp(handle, bufb->chan)->backend;
	if (!chanb)
		abort();
	config = &chanb->config;

	num_subbuf_alloc = chanb->num_subbuf;
	if (chanb->extra_reader_sb)
		num_subbuf_alloc++;

	for (i = 0; i < chanb->num_subbuf; i++) {
		struct lttng_ust_lib_ring_buffer_backend_subbuffer *sb;

		sb = shmp_index(handle, bufb->buf_wsb, i);
		if (!sb)
			abort();
		sb->id = subbuffer_id(config, 0, 1, i);
	}
	if (chanb->extra_reader_sb)
		bufb->buf_rsb.id = subbuffer_id(config, 0, 1,
						num_subbuf_alloc - 1);
	else
		bufb->buf_rsb.id = subbuffer_id(config, 0, 1, 0);

	for (i = 0; i < num_subbuf_alloc; i++) {
		struct lttng_ust_lib_ring_buffer_backend_pages_shmp *sbp;
		struct lttng_ust_lib_ring_buffer_backend_pages *pages;

		sbp = shmp_index(handle, bufb->array, i);
		if (!sbp)
			abort();
		pages = shmp(handle, sbp->shmp);
		if (!pages)
			abort();
		/* Don't reset mmap_offset */
		v_set(config, &pages->records_commit, 0);
		v_set(config, &pages->records_unread, 0);
		pages->data_size = 0;
		/* Don't reset backend page and virt addresses */
	}
	/* Don't reset num_pages_per_subbuf, cpu, allocated */
	v_set(config, &bufb->records_read, 0);
}
Ejemplo n.º 4
0
/* The q_space parameter must have enough storage capacity for 7 quaternion structures */
void mol_rotate(cVector *axis, cVector *origin, float phi, quaternion *q_space, cTetrahedron *target)
{
	int i;
	quaternion *to_rotate, *q_target;
	cVector *ptr_axis;
	to_rotate = q_space++;
	q_target = q_space++;
	
	ptr_axis = (cVector *) malloc(sizeof(cVector));
	for(i = 0; i < 5; i++)
	{
		v_set(ptr_axis, axis->x, axis->y, axis->z);
		q_set(q_target, 0, 0, 0, 0);
		to_rotate->s = 0;
		to_rotate->v.x = target->cAtoms[i].v.x;
		to_rotate->v.y = target->cAtoms[i].v.y;
		to_rotate->v.z = target->cAtoms[i].v.z;

		q_rotate(to_rotate, ptr_axis, origin, phi, q_space, q_target);

		target->cAtoms[i].v.x = q_target->v.x;
		target->cAtoms[i].v.y = q_target->v.y;
		target->cAtoms[i].v.z = q_target->v.z;
	}

	free(ptr_axis);

}
Ejemplo n.º 5
0
void put_inside(cVector corner, cTetrahedron *curr)
{
	int x = 0, y = 0, z = 0;
	cVector pos = curr->cAtoms[0].v;
	cVector translate;
	
	if(pos.x > corner.x)
		x = -1;
	else if(pos.x < 0)
		x = 1;

	if(pos.y > corner.y)
		y = -1;
	else if(pos.y < 0)
		y = 1;

	if(pos.z > corner.z)
		z = -1;
	else if(pos.z < 0)
		z = 1;

	if(x != 0 || y != 0 || z != 0)
	{
		v_set(&translate, x * corner.x, y * corner.y, z * corner.z);
		mol_translate(&translate, 5, curr);
	}
		
}
Ejemplo n.º 6
0
bool ImpuzzableTicker::OpenUiManager() {
	bool ok = true;
	if (ok) {
		ok = ui_manager_->OpenDraw();
	}
	if (ok) {
		uilepra::Core::ProcessMessages();
	}
	if (ok) {
		ui_manager_->UpdateSettings();
		uitbc::Renderer* renderer = ui_manager_->GetRenderer();
		renderer->AddDynamicRenderer("particle", new uitbc::ParticleRenderer(renderer, 0));
		UiCure::ParticleLoader loader(resource_manager_, renderer, "explosion.png", 4, 5);
	}
	if (ok) {
		env_map_ = new UiCure::RendererImageResource(ui_manager_, resource_manager_, "env.png", UiCure::ImageProcessSettings(Canvas::kResizeFast, true));
		if (env_map_->Load()) {
			if (env_map_->PostProcess() == cure::kResourceLoadComplete) {
				uitbc::Renderer::TextureID texture_id = env_map_->GetUserData(0);
				ui_manager_->GetRenderer()->SetEnvironmentMap(texture_id);
			}
		}
	}
	if (ok) {
		if (ui_manager_->GetCanvas()->GetHeight() < 600) {
			double font_height;
			v_get(font_height, =, UiCure::GetSettings(), kRtvarUi2DFontheight, 30.0);
			if (font_height > 29.0) {
				font_height *= ui_manager_->GetCanvas()->GetHeight()/600.0;
				v_set(UiCure::GetSettings(), kRtvarUi2DFontheight, font_height);
			}
		}
		ok = ui_manager_->OpenRest();
	}
Ejemplo n.º 7
0
/*
 * return a full copy of the 'source'
 */
var_t *v_clone(const var_t *source) {
  var_t *vnew;

  vnew = (var_t *) tmp_alloc(sizeof(var_t));
  v_init(vnew);
  v_set(vnew, source);
  return vnew;
}
Ejemplo n.º 8
0
void PushViewer::LoadSettings() {
	v_set(GetVariableScope(), kRtvarDebugInputPrint, false);

	v_internal(GetVariableScope(), kRtvarUi3DCamdistance, 20.0);
	v_internal(GetVariableScope(), kRtvarUi3DCamheight, 10.0);
	v_internal(GetVariableScope(), kRtvarUi3DCamrotate, 0.0);
	v_internal(GetVariableScope(), kRtvarSteeringPlaybackmode, kPlaybackNone);
}
Ejemplo n.º 9
0
/*
 * assign (dest = src)
 */
void v_set(var_t *dest, const var_t *src) {
  int i;
  var_t *dest_vp, *src_vp;

  if (src->type == V_UDS) {
    uds_set(dest, (const var_p_t) src);
    return;
  } else if (dest->type == V_UDS) {
    // lvalue struct assigned to non-struct rvalue
    uds_clear(dest);
    return;
  } else if (src->type == V_HASH) {
    hash_set(dest, (const var_p_t) src);
    return;
  } else if (dest->type == V_HASH) {
    // lvalue struct assigned to non-struct rvalue
    hash_clear(dest);
    return;
  }

  v_free(dest);
  *dest = *src;
  dest->const_flag = 0;
  switch (src->type) {
  case V_STR:
    dest->v.p.ptr = (byte *) tmp_alloc(strlen((char *)src->v.p.ptr) + 1);
    strcpy((char *) dest->v.p.ptr, (char *) src->v.p.ptr);
    break;

  case V_ARRAY:
    if (src->v.a.size) {
      dest->v.a.ptr = tmp_alloc(src->v.a.size * sizeof(var_t));

      // copy each element
      for (i = 0; i < src->v.a.size; i++) {
        src_vp = (var_t *) (src->v.a.ptr + (sizeof(var_t) * i));
        dest_vp = (var_t *) (dest->v.a.ptr + (sizeof(var_t) * i));
        v_init(dest_vp);
        v_set(dest_vp, src_vp);
      }
    } else {
      dest->v.a.size = 0;
      dest->v.a.ptr = NULL;
      dest->v.a.ubound[0] = dest->v.a.lbound[0] = opt_base;
      dest->v.a.maxdim = 1;
    }
    break;

  case V_PTR:
    dest->v.ap = src->v.ap;
    dest->type = src->type;
    break;
  }
}
Ejemplo n.º 10
0
/*
 * assign (dest = src)
 */
void v_set(var_t *dest, const var_t *src) {
  v_free(dest);
  dest->const_flag = 0;
  dest->type = src->type;

  switch (src->type) {
  case V_INT:
    dest->v.i = src->v.i;
    break;
  case V_STR:
    dest->v.p.size = strlen(src->v.p.ptr) + 1;
    dest->v.p.ptr = (char *)malloc(dest->v.p.size);
    strcpy(dest->v.p.ptr, src->v.p.ptr);
    break;
  case V_NUM:
    dest->v.n = src->v.n;
    break;
  case V_MAP:
    map_set(dest, (const var_p_t)src);
    break;
  case V_PTR:
    dest->v.ap.p = src->v.ap.p;
    dest->v.ap.v = src->v.ap.v;
    break;
  case V_REF:
    dest->v.ref = src->v.ref;
    break;
  case V_FUNC:
    dest->v.fn.cb = src->v.fn.cb;
    dest->v.fn.self = src->v.fn.self;
    break;
  case V_ARRAY:
    if (src->v.a.size) {
      memcpy(&dest->v.a, &src->v.a, sizeof(src->v.a));
      dest->v.a.ptr = malloc(src->v.a.size * sizeof(var_t));

      // copy each element
      int i;
      var_t *dest_vp, *src_vp;
      for (i = 0; i < src->v.a.size; i++) {
        src_vp = (var_t *)(src->v.a.ptr + (sizeof(var_t) * i));
        dest_vp = (var_t *)(dest->v.a.ptr + (sizeof(var_t) * i));
        v_init(dest_vp);
        v_set(dest_vp, src_vp);
      }
    } else {
      dest->v.a.size = 0;
      dest->v.a.ptr = NULL;
      dest->v.a.ubound[0] = dest->v.a.lbound[0] = opt_base;
      dest->v.a.maxdim = 1;
    }
    break;
  }
}
Ejemplo n.º 11
0
void sm_frame(sm_t *sm,int from,int to,float frame) {
	int i,frame0,frame1;
	if(from == -1) from = 0;
	if(to == -1) to = sm->num_frame;
	frame0 = (int)frame;
	frame -= frame0;
	frame0 += from;
	if(frame0 >= to) frame0 = ((frame0 - from) % (to - from)) + from;
	frame1 = frame0 + 1;
	if(frame1 >= to) frame1 = from;
	for(i = 0; i < sm->num_bone; i++) {
		float m0[16],m1[16];
		float xyz0[3],xyz1[3],xyz[3],rot[4];
		v_scale(sm->frame[frame0][i].xyz,1.0 - frame,xyz0);
		v_scale(sm->frame[frame1][i].xyz,frame,xyz1);
		v_add(xyz0,xyz1,xyz);
		q_slerp(sm->frame[frame0][i].rot,sm->frame[frame1][i].rot,frame,rot);
		m_translate(xyz,m0);
		q_to_matrix(rot,m1);
		m_multiply(m0,m1,sm->bone[i].matrix);
	}
	for(i = 0; i < sm->num_surface; i++) {
		int j;
		sm_surface_t *s = sm->surface[i];
		for(j = 0; j < s->num_vertex; j++) {
			int k;
			v_set(0,0,0,s->vertex[j].xyz);
			v_set(0,0,0,s->vertex[j].normal);
			for(k = 0; k < s->vertex[j].num_weight; k++) {
				float v[3];
				sm_weight_t *w = &s->vertex[j].weight[k];
				v_transform(w->xyz,sm->bone[w->bone].matrix,v);
				v_scale(v,w->weight,v);
				v_add(s->vertex[j].xyz,v,s->vertex[j].xyz);
				v_transform_normal(w->normal,sm->bone[w->bone].matrix,v);
				v_scale(v,w->weight,v);
				v_add(s->vertex[j].normal,v,s->vertex[j].normal);
			}
		}
	}
}
Ejemplo n.º 12
0
int Reaching::SetActualRobPosition(joint_vec_t& angles){
  if(AcceptablePosition(angles)){
    v4_copy(angles,pos_angle);
    v4_set(0,0,0,0,v_angle);
    v_set(0,0,0,v_cart);
    Angle2Cart(pos_angle,pos_cart);
    CVector2ArmConfig(pos_angle,&position);
    v_clear(tar_angle);
    return 1;
  }
  else{
    return 0;
  }
} 
Ejemplo n.º 13
0
void PushViewer::OnButtonClick(uitbc::Button* button) {
	if (button->GetName() == "server") {
		if (!server_list_view_) {
			GetMaster()->DownloadServerList();
			server_list_view_ = new ServerListView(this);
			ui_manager_->AssertDesktopLayout(new uitbc::CenterLayout, 1);
			ui_manager_->GetDesktopWindow()->AddChild(server_list_view_, 0, 0, 1);
		}
		v_set(GetVariableScope(), kRtvarNetworkEnableonlinemaster, true);
		return;
	}
	if (button->GetName() == "quit") {
		GetMaster()->OnExit();
		return;
	}
	int value = 0;
	if (strutil::StringToInt(button->GetName(), value)) {
		GetMaster()->OnSetPlayerCount(value);
	} else {
		deb_assert(false);
	}
}
Ejemplo n.º 14
0
/*
 * add two variables
 * result = a + b
 */
void v_add(var_t *result, var_t *a, var_t *b) {
  char tmpsb[INT_STR_LEN];

  if (a->type == V_STR && b->type == V_STR) {
    int length = strlen(a->v.p.ptr) + strlen(b->v.p.ptr);
    result->type = V_STR;
    result->v.p.ptr = malloc(length + 1);
    strcpy(result->v.p.ptr, a->v.p.ptr);
    strcat(result->v.p.ptr, b->v.p.ptr);
    result->v.p.ptr[length] = '\0';
    result->v.p.length = length + 1;
    return;
  } else if (a->type == V_INT && b->type == V_INT) {
    result->type = V_INT;
    result->v.i = a->v.i + b->v.i;
    return;
  } else if (a->type == V_NUM && b->type == V_NUM) {
    result->type = V_NUM;
    result->v.n = a->v.n + b->v.n;
    return;
  } else if (a->type == V_NUM && b->type == V_INT) {
    result->type = V_NUM;
    result->v.n = a->v.n + b->v.i;
    return;
  } else if (a->type == V_INT && b->type == V_NUM) {
    result->type = V_NUM;
    result->v.n = a->v.i + b->v.n;
    return;
  } else if (a->type == V_STR && (b->type == V_INT || b->type == V_NUM)) {
    if (is_number(a->v.p.ptr)) {
      result->type = V_NUM;
      if (b->type == V_INT) {
        result->v.n = b->v.i + v_getval(a);
      } else {
        result->v.n = b->v.n + v_getval(a);
      }
    } else {
      result->type = V_STR;
      result->v.p.ptr = (char *)malloc(strlen(a->v.p.ptr) + INT_STR_LEN);
      strcpy(result->v.p.ptr, a->v.p.ptr);
      if (b->type == V_INT) {
        ltostr(b->v.i, tmpsb);
      } else {
        ftostr(b->v.n, tmpsb);
      }
      strcat(result->v.p.ptr, tmpsb);
      result->v.p.length = strlen(result->v.p.ptr) + 1;
    }
  } else if ((a->type == V_INT || a->type == V_NUM) && b->type == V_STR) {
    if (is_number(b->v.p.ptr)) {
      result->type = V_NUM;
      if (a->type == V_INT) {
        result->v.n = a->v.i + v_getval(b);
      } else {
        result->v.n = a->v.n + v_getval(b);
      }
    } else {
      result->type = V_STR;
      result->v.p.ptr = (char *)malloc(strlen(b->v.p.ptr) + INT_STR_LEN);
      if (a->type == V_INT) {
        ltostr(a->v.i, tmpsb);
      } else {
        ftostr(a->v.n, tmpsb);
      }
      strcpy(result->v.p.ptr, tmpsb);
      strcat(result->v.p.ptr, b->v.p.ptr);
      result->v.p.length = strlen(result->v.p.ptr) + 1;
    }
  } else if (b->type == V_MAP) {
    char *map = map_to_str(b);
    v_set(result, a);
    v_strcat(result, map);
    free(map);
  }
}
Ejemplo n.º 15
0
void PushViewer::OnRequestJoinServer(const str& server_address) {
	v_set(GetVariableScope(), kRtvarNetworkServeraddress, server_address);
	v_internal(UiCure::GetSettings(), kRtvarLoginIsserverselected, true);
	log_.Infof("Will use server %s when logging in.", server_address.c_str());
	CloseJoinServerView();
}
Ejemplo n.º 16
0
static int MainShadow(int ac, char **av, bool *pbTableSort )
{
    
    
    
    int nError = ERROR_NONE;
    bool bDoAllPasses = false;
    int nMaxPasses = 10;
    
    char buf[MAXLINE];
    int i;
    MNEMONIC *mne;
    
    int oldredo = -1;
    unsigned long oldwhy = 0;
    int oldeval = 0;
    
    addhashtable(Ops);
    pass = 1;

    if (ac < 2)
    {

fail:
    puts(dasm_id);
    puts("Copyright (c) 1988-2008 by various authors (see file AUTHORS).");
    puts("License GPLv2+: GNU GPL version 2 or later (see file COPYING).");
    puts("DASM is free software: you are free to change and redistribute it.");
    puts("There is ABSOLUTELY NO WARRANTY, to the extent permitted by law.");
    puts("");
    puts("Usage: dasm sourcefile [options]");
    puts("");
    puts("-f#      output format 1-3 (default 1)");
    puts("-oname   output file name (else a.out)");
    puts("-lname   list file name (else none generated)");
    puts("-Lname   list file, containing all passes");
    puts("-sname   symbol dump file name (else none generated)");
    puts("-v#      verboseness 0-4 (default 0)");
    puts("-d       debug mode (for developers)");
    puts("-Dsymbol              define symbol, set to 0");
    puts("-Dsymbol=expression   define symbol, set to expression");
    puts("-Msymbol=expression   define symbol using EQM (same as -D)");
    puts("-Idir    search directory for INCLUDE and INCBIN");
    puts("-p#      maximum number of passes");
    puts("-P#      maximum number of passes, with fewer checks");
    puts("-T#      symbol table sorting (default 0 = alphabetical, 1 = address/value)");
    puts("-E#      error format (default 0 = MS, 1 = Dillon, 2 = GNU)");
    puts("");
    puts("Report bugs to [email protected] please!");

    return ERROR_COMMAND_LINE;
    }
    
    for (i = 2; i < ac; ++i)
    {
        if ( ( av[i][0] == '-' ) || ( av[i][0] == '/' ) )
        {
            char *str = av[i]+2;
            switch(av[i][1])
            {
            /* TODO: need to improve option parsing and errors for it */
            case 'E':
                F_errorformat = atoi(str);
                if (F_errorformat < ERRORFORMAT_DEFAULT
                   || F_errorformat >= ERRORFORMAT_MAX )
                {
                    panic("Invalid error format for -E, must be 0, 1, 2");
                }
                break;

            case 'T':
                F_sortmode = atoi(str);
                if (F_sortmode < SORTMODE_DEFAULT
                   || F_sortmode >= SORTMODE_MAX )
                {
                    panic("Invalid sorting mode for -T option, must be 0 or 1");
                }
                /* TODO: refactor into regular configuration [phf] */
                *pbTableSort = (F_sortmode != SORTMODE_DEFAULT);
                break;
                
            case 'd':
                Xdebug = atoi(str) != 0;
                printf( "Debug trace %s\n", Xdebug ? "ON" : "OFF" );
                break;
                
            case 'M':
            case 'D':
                while (*str && *str != '=')
                    ++str;
                if (*str == '=')
                {
                    *str = 0;
                    ++str;
                }
                else
                {
                    str = "0";
                }
                Av[0] = av[i]+2;
                
                if (av[i][1] == 'M')
                    v_eqm(str, NULL);
                else
                    v_set(str, NULL);
                break;
                
            case 'f':   /*  F_format    */
                F_format = atoi(str);
                if (F_format < FORMAT_DEFAULT || F_format >= FORMAT_MAX )
                    panic("Illegal format specification");
                break;
                
            case 'o':   /*  F_outfile   */
                F_outfile = str;
nofile:
                if (*str == 0)
                    panic("-o Switch requires file name.");
                break;

            case 'L':
                F_ListAllPasses = 1;
                /* fall through to 'l' */

            case 'l':   /*  F_listfile  */
                F_listfile = str;
                goto nofile;
                
            case 'P':   /*  F_Passes   */
                bDoAllPasses = true;
                
                /* fall through to 'p' */
            case 'p':   /*  F_passes   */
                nMaxPasses = atoi(str);
                break;
                
            case 's':   /*  F_symfile   */
                F_symfile = str;
                goto nofile;
            case 'v':   /*  F_verbose   */
                F_verbose = atoi(str);
                break;
                
            case 'I':
                v_incdir(str, NULL);
                break;
                
            default:
                goto fail;
            }
            continue;
        }
        goto fail;
    }
    
    /*    INITIAL SEGMENT */
    
    {
        SEGMENT *seg = (SEGMENT *)permalloc(sizeof(SEGMENT));
        seg->name = strcpy(permalloc(sizeof(ISEGNAME)), ISEGNAME);
        seg->flags= seg->rflags = seg->initflags = seg->initrflags = SF_UNKNOWN;
        Csegment = Seglist = seg;
    }
    /*    TOP LEVEL IF    */
    {
        IFSTACK *ifs = (IFSTACK *)zmalloc(sizeof(IFSTACK));
        ifs->file = NULL;
        ifs->flags = IFF_BASE;
        ifs->acctrue = 1;
        ifs->xtrue  = 1;
        Ifstack = ifs;
    }
    
    
nextpass:
    
    
    if ( F_verbose )
    {
        puts("");
        printf("START OF PASS: %d\n", pass);
    }
    
    Localindex = Lastlocalindex = 0;
    
    Localdollarindex = Lastlocaldollarindex = 0;
    
    /*_fmode = 0x8000;*/
    FI_temp = fopen(F_outfile, "wb");
    /*_fmode = 0;*/
    Fisclear = 1;
    CheckSum = 0;
    if (FI_temp == NULL) {
        printf("Warning: Unable to [re]open '%s'\n", F_outfile);
        return ERROR_FILE_ERROR;
    }
    if (F_listfile) {

        FI_listfile = fopen(F_listfile,
            F_ListAllPasses && (pass > 1)? "a" : "w");

        if (FI_listfile == NULL) {
            printf("Warning: Unable to [re]open '%s'\n", F_listfile);
            return ERROR_FILE_ERROR;
        }
    }
    pushinclude(av[1]);
    
    while ( pIncfile )
    {
        for (;;) {
            const char *comment;
            if ( pIncfile->flags & INF_MACRO) {
                if ( pIncfile->strlist == NULL) {
                    Av[0] = "";
                    v_mexit(NULL, NULL);
                    continue;
                }
                strcpy(buf, pIncfile->strlist->buf);
                pIncfile->strlist = pIncfile->strlist->next;
            }
            else
            {
                if (fgets(buf, MAXLINE, pIncfile->fi) == NULL)
                    break;
            }
            
            if (Xdebug)
                printf("%08lx %s\n", (unsigned long) pIncfile, buf);
            
            comment = cleanup(buf, false);
            ++pIncfile->lineno;
            mne = parse(buf);
            
            if (Av[1][0])
            {
                if (mne)
                {
                    if ((mne->flags & MF_IF) || (Ifstack->xtrue && Ifstack->acctrue))
                        (*mne->vect)(Av[2], mne);
                }
                else
                {
                    if (Ifstack->xtrue && Ifstack->acctrue)
                        asmerr( ERROR_UNKNOWN_MNEMONIC, false, Av[1] );
                }
                
            }
            else
            {
                if (Ifstack->xtrue && Ifstack->acctrue)
                    programlabel();
            }
            
            if (F_listfile && ListMode)
                outlistfile(comment);
        }
        
        while (Reploop && Reploop->file == pIncfile)
            rmnode((void **)&Reploop, sizeof(REPLOOP));
        
        while (Ifstack->file == pIncfile)
            rmnode((void **)&Ifstack, sizeof(IFSTACK));
        
        fclose( pIncfile->fi );
        free( pIncfile->name );
        --Inclevel;
        rmnode((void **)&pIncfile, sizeof(INCFILE));
        
        if ( pIncfile )
        {
        /*
        if (F_verbose > 1)
        printf("back to: %s\n", Incfile->name);
            */
            if (F_listfile)
                fprintf(FI_listfile, "------- FILE %s\n", pIncfile->name);
        }
    }
    
    
    
    if ( F_verbose >= 1 )
        ShowSegments();
    
    if ( F_verbose >= 3 )
    {
        if ( !Redo || ( F_verbose == 4 ) )
            ShowSymbols( stdout, *pbTableSort );
        
        ShowUnresolvedSymbols();
    }
    
    closegenerate();
    fclose(FI_temp);
    if (FI_listfile)
        fclose(FI_listfile);
    
    if (Redo)
    {
        if ( !bDoAllPasses )
            if (Redo == oldredo && Redo_why == oldwhy && Redo_eval == oldeval)
            {
                ShowUnresolvedSymbols();
                return ERROR_NOT_RESOLVABLE;
            }
            
            oldredo = Redo;
            oldwhy = Redo_why;
            oldeval = Redo_eval;
            Redo = 0;
            Redo_why = 0;
            Redo_eval = 0;

            Redo_if <<= 1;
            ++pass;
            
            if ( bStopAtEnd )
            {
                printf("Unrecoverable error(s) in pass, aborting assembly!\n");
            }
            else if ( pass > nMaxPasses )
            {
                char sBuffer[64];
                sprintf( sBuffer, "%d", pass );
                return asmerr( ERROR_TOO_MANY_PASSES, false, sBuffer );
                
            }
            else
            {
                clearrefs();
                clearsegs();
                goto nextpass;
            }
    }
    
    return nError;
}
Ejemplo n.º 17
0
/* init
 */
int init(void) {
	int i,num_vertex,width,height;
	float *vertex;
	unsigned char *data;
	float rmax;
	vec3 min,max;
    vec4 plane_s = { 1.0, 0.0, 0.0, 0.0 };
    vec4 plane_t = { 0.0, 1.0, 0.0, 0.0 };
    vec4 plane_r = { 0.0, 0.0, 1.0, 0.0 };
    vec4 plane_q = { 0.0, 0.0, 0.0, 1.0 };
	GLenum err;

	err = glewInit();
	if (GLEW_OK != err)
	{
		fprintf(stderr, "glewInit() error: %s\n", glewGetErrorString(err));
	}

	glClearDepth(1);
    glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
    glEnable(GL_LIGHT0);
	glPointSize(4);
	glTexGenfv(GL_S,GL_EYE_PLANE,plane_s);
	glTexGenfv(GL_T,GL_EYE_PLANE,plane_t);
	glTexGenfv(GL_R,GL_EYE_PLANE,plane_r);
	glTexGenfv(GL_Q,GL_EYE_PLANE,plane_q);
	glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
	glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
	glTexGeni(GL_R,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
	glTexGeni(GL_Q,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);

	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
	glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,SIZE,SIZE,0,GL_RGB,
		GL_UNSIGNED_BYTE,NULL);
	
	glGenTextures(1,&texture_id);
	glBindTexture(GL_TEXTURE_2D,texture_id);
	if((data = load_jpeg("data/ground.jpg",&width,&height))) {
		glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,
			GL_LINEAR_MIPMAP_LINEAR);
		glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,
			GL_LINEAR_MIPMAP_LINEAR);
		gluBuild2DMipmaps(GL_TEXTURE_2D,4,width,height,GL_RGBA,
			GL_UNSIGNED_BYTE,data);
		free(data);
	}
	
	vertex = load_3ds("data/mesh.3ds",&num_vertex);
	if(!vertex) return -1;
	
	v_set(999999,999999,999999,min);
	v_set(-999999,-999999,-999999,max);
    for(i = 0; i < num_vertex; i++) {
		int j;
		float *v = &vertex[i << 3];
		for(j = 0; j < 3; j++) {
			if(min[j] > v[j]) min[j] = v[j];
			if(max[j] < v[j]) max[j] = v[j];
		}
    }
	v_add(min,max,min);
	v_scale(min,0.5,min);
    for(i = 0; i < num_vertex; i++) {
        v_sub(&vertex[i << 3],min,&vertex[i << 3]);
    }
    for(i = 0, rmax = 0; i < num_vertex; i++) {
        float r = sqrt(v_dot(&vertex[i << 3],&vertex[i << 3]));
		if(r > rmax) rmax = r;
    }
	rmax = 0.8 / rmax;
    for(i = 0; i < num_vertex; i++) {
        v_scale(&vertex[i << 3],rmax,&vertex[i << 3]);
    }
	
    mesh_id = glGenLists(1);
	glNewList(mesh_id,GL_COMPILE);
    glBegin(GL_TRIANGLES);
    for(i = 0; i < num_vertex; i++) {
        glNormal3fv((float*)&vertex[i << 3] + 3);
        glVertex3fv((float*)&vertex[i << 3]);
    }
    glEnd();
    glEndList();
	
	vertex = load_3ds("data/ground.3ds",&num_vertex);
	if(!vertex) return -1;
	
    ground_id = glGenLists(1);
	glNewList(ground_id,GL_COMPILE);
    glBegin(GL_TRIANGLES);
    for(i = 0; i < num_vertex; i++) {
		glTexCoord2fv((float*)&vertex[i << 3] + 6);
		glNormal3fv((float*)&vertex[i << 3] + 3);
        glVertex3fv((float*)&vertex[i << 3]);
    }
    glEnd();
    glEndList();
	
	image = malloc(SIZE * SIZE * 4);
	
	return 0;
}
Ejemplo n.º 18
0
//--------------------------------------------------------------------------
void Omu_IntRKsuite::ode_solve(double tstart, VECP y, const VECP u,
			       double tend)
{
  if (_sa)
    _neq = y->dim;
  else
    _neq = _n;
  _npar = u->dim;

  v_resize(_work, 32 * _neq);
  v_resize(_thres, _neq);
  v_resize(_u, _npar);
  v_resize(_yp, _neq);
  _y_head.dim = _neq;
  _yp_head.dim = _neq;

  v_set(_thres, _atol);

  // exclude sensitivities from error test
  if (!_serr) {
    for (int i = _n; i < (int)_thres->dim; i++)
      _thres[i] = 1e128;
  }

  v_zero(_yp);
  v_copy(u, _u);

  integer NEQ = _neq;

  // a hack to reinitialize _hnext in each simulation
  if (tstart < _tlast)
    _hnext = 0.0;
  _tlast = tstart;

  dreal TNOW = tstart;
  integer CFLAG;

  //integer METHOD = (_rtol > 5e-4)? 1: (_rtol > 5e-6)? 2: 3;
  integer METHOD = _method;
  char TASK = 'c';
  logical ERRASS = 0;
  dreal HSTART = _hnext;
  integer LENWRK = _work->dim;
  logical MESAGE = 0;

  setup_(&NEQ, &tstart, y->ve, &tend, &_rtol, _thres->ve,
	 &METHOD, &TASK, &ERRASS, &HSTART, _work->ve, &LENWRK, &MESAGE);

  while (TNOW < tend) {
    ct_(&::F, &TNOW, y->ve, _yp->ve, _work->ve, &CFLAG);
    if (CFLAG > 1)
      fprintf(stderr, "RKsuite message %d at time %g\n", CFLAG, TNOW);
    if (CFLAG > 4)
      m_error(E_CONV, "Omu_IntRKsuite::step");
  }

  integer TOTF, STPCST, STPSOK;
  dreal WASTE;
  stat_(&TOTF, &STPCST, &WASTE, &STPSOK, &HSTART);
  _hnext = HSTART;
}
Ejemplo n.º 19
0
/**
 * execute a call to a unit
 */
int unit_exec(int lib_id, int index, var_t * ret) {
  unit_sym_t *us;               // unit's symbol data
  bc_symbol_rec_t *ps;          // program's symbol data
  int my_tid;
  stknode_t udf_rv;

  my_tid = ctask->tid;
  ps = &prog_symtable[index];
  us = &(taskinfo(ps->task_id)->sbe.exec.exptable[ps->exp_idx]);

  //
  switch (ps->type) {
  case stt_variable:
    break;
  case stt_procedure:
    exec_sync_variables(1);

    cmd_call_unit_udp(kwPROC, ps->task_id, us->address, 0);

    activate_task(ps->task_id);
    if (prog_error) {
      gsb_last_error = prog_error;
      taskinfo(my_tid)->error = gsb_last_error;
      return 0;
    }
    bc_loop(2);
    if (prog_error) {
      gsb_last_error = prog_error;
      taskinfo(my_tid)->error = gsb_last_error;
      return 0;
    }
    activate_task(my_tid);
    exec_sync_variables(0);
    break;

  case stt_function:
    exec_sync_variables(1);

    cmd_call_unit_udp(kwFUNC, ps->task_id, us->address, us->vid);

    activate_task(ps->task_id);
    if (prog_error) {
      gsb_last_error = prog_error;
      taskinfo(my_tid)->error = gsb_last_error;
      return 0;
    }
    bc_loop(2);
    if (prog_error) {
      gsb_last_error = prog_error;
      taskinfo(my_tid)->error = gsb_last_error;
      return 0;
    }
    // get last variable from stack
    code_pop(&udf_rv, kwTYPE_RET);
    if (udf_rv.type != kwTYPE_RET) {
      err_stackmess();
    } else {
      v_set(ret, udf_rv.x.vdvar.vptr);
      v_free(udf_rv.x.vdvar.vptr);  // free ret-var
      free(udf_rv.x.vdvar.vptr);
    }

    activate_task(my_tid);
    exec_sync_variables(0);
    break;
  };

  return (prog_error == 0);
}
Ejemplo n.º 20
0
/*
 * return a full copy of the 'source'
 */
var_t *v_clone(const var_t *source) {
  var_t *vnew = v_new();
  v_set(vnew, source);
  return vnew;
}