예제 #1
0
size_t BufferedFile::get_bytes(address buffer, jint num, bool is_buffered) {
  jint total_read = 0;
  Buffer::Raw fb = data_buffer();

  if (!is_buffered) {
    OsFile_seek(file_pointer(), (long)(-(count() - index())), SEEK_CUR);
    set_count(0);    // flush buffer
    set_index(0);
    return OsFile_read(file_pointer(), buffer, 1, num);

  } else {
    while (!at_eof() && num > 0) {
      int num_to_read = (num > (count() - index())) ? (count() - index()) :num;
      // num_to_read may be zero
      if (num_to_read) {
        jvm_memcpy(buffer, fb().base_address() + (index() * sizeof (jbyte)), 
                   num_to_read);
        buffer += num_to_read;
        num -= num_to_read;
        set_index(index() + num_to_read);
        total_read += num_to_read;
      }
      if (num > 0) {
        refill_buffer();
      }
    }
  }
  return total_read;
}
예제 #2
0
int BufferedFile::seek(jint offset, int origin) {
  int ndx = index();
  int cnt = count();
  switch (origin) {
  case SEEK_CUR:
    // we may have data in the buffer so seek relative to current index into
    // buffer
    if (cnt > 0) {
      // we have some data, so seek from current index
      if (offset + ndx >= 0 && offset + ndx < cnt) {
        // we are seeking somewhere in the buffer, just set the ndx and return
        set_index((int) (ndx + offset));
        return 0;
      } else {
        // we are seeking out of buffer, do a SEEK_CUR to the right position
        offset -= (cnt - ndx);
        set_file_pos((long)(file_pos() + offset));
      }
    }
    break;
  case SEEK_SET:
    if (cnt > 0) {
      if (offset >= (file_pos() - cnt) && offset < file_pos()) {
        // we're seeking in the buffer so just adjust pointer
        set_index((int) (cnt - (file_pos() - offset)));
        return 0;
      }
    }
    set_file_pos(offset);
    break;
  case SEEK_END:
    if (cnt > 0) {
      if (cnt == file_size()) {
        // The whole thing is in the buffer so just adjust the index
        if ((cnt + offset ) >= 0) {
          set_index((int) (cnt + offset));
          return 0;
        }
      }
      // There's more data beyond what we have in the buffer so just seek there
    }
    set_file_pos(long(file_size() + offset));
    break;
  }
  set_count(0);    // flush buffer
  set_index(0);

  if (file_pos() < file_size()) {
    set_at_eof(false);
  }
  return (int) OsFile_seek(file_pointer(), offset, origin);
}
예제 #3
0
value* ssa_rename::rename_def(node *n, value* v) {
	unsigned index;

	if (v->is_lds_access()) {
		index = new_index(lds_rw_count, v);
		set_index(rename_lds_rw_stack.top(), v, index);
	} else {
		index = new_index(def_count, v);
		set_index(rename_stack.top(), v, index);
	}
	value *r = sh.get_value_version(v, index);
	return r;
}
예제 #4
0
static int build_response(const http_request_t *request,http_response_t *response)
{
	char buffer[MAX_HEADER_VALUE_LENGTH];
	int head_count=0;
	time_t now=0;
	struct tm *t;
	strcat(response->resource_path,request->uri);
	set_index(response->resource_path);	

	response->status        = check_response_status(request->method,response->resource_path);
	handle_error(response->status, response->resource_path);

	response->major_version = request->major_version;
	response->minor_version = request->minor_version;

	now = time(NULL);
	t = gmtime(&now);
	strftime(buffer,30,"%a, %d %b %Y %H:%M:%S %Z",t);

	set_response_field_name_and_value(response,"Date",buffer);
	set_response_field_name_and_value(response,"Server","CSUC HTTP");
	set_response_field_name_and_value(response,"Content-Type",get_extension(response->resource_path));
	sprintf(buffer,"%d",file_size(response->resource_path));
	add_to_total_size(atoi(buffer));
	set_response_field_name_and_value(response,"Content-Length",buffer);

	return 1;
}
예제 #5
0
void BufferedFile::refill_buffer() {
  if (at_eof()) {
    return;
  }
  int bytes_to_read = buffer_size();
  int max = file_size() - file_pos();
  if (bytes_to_read > max) {
    bytes_to_read = max;
  }

  int count_read;
  {
    // The file_pointer() may be shared with a FileDecoder
    // object. This may cause BufferedFile::file_pos() to become out
    // of date. A call to OsFile_seek() makes everything consistent again.
    AllocationDisabler raw_pointers_used_in_this_block;
    Buffer::Raw fb = data_buffer();
    OsFile_seek(file_pointer(), file_pos(), SEEK_SET);
    count_read = OsFile_read(file_pointer(), fb().base_address(),
                             1, bytes_to_read);
  }

  set_count(count_read);
  set_file_pos(long(file_pos() + count_read));
  set_index(0);
  if (count_read <= 0) {
     set_at_eof(true);
  }
  return;
}
예제 #6
0
void local_flush_tlb_all(void)
{
	unsigned long flags;
	unsigned long old_ctx;
	int entry;

#ifdef DEBUG_TLB
	printk("[tlball]");
#endif

	__save_and_cli(flags);
	/* Save old context and create impossible VPN2 value */
	old_ctx = (get_entryhi() & 0xff);
	set_entryhi(KSEG0);
	set_entrylo0(0);
	set_entrylo1(0);
	BARRIER;

	entry = get_wired();

	/* Blast 'em all away. */
	while(entry < mips_cpu.tlbsize) {
	        /* Make sure all entries differ. */
	        set_entryhi(KSEG0+entry*0x2000);
		set_index(entry);
		BARRIER;
		tlb_write_indexed();
		BARRIER;
		entry++;
	}
	BARRIER;
	set_entryhi(old_ctx);
	__restore_flags(flags);
}
예제 #7
0
value* ssa_rename::rename_use(node *n, value* v) {
	if (v->version)
		return v;
	unsigned index;
	if (v->is_lds_access()) {
		index = get_index(rename_lds_rw_stack.top(), v);
	} else if (v->is_lds_oq()) {
		index = new_index(lds_oq_count, v);
		set_index(rename_lds_oq_stack.top(), v, index);
	} else {
		index = get_index(rename_stack.top(), v);
	}

	v = sh.get_value_version(v, index);

	// if (alu) instruction is predicated and source arg comes from psi node
	// (that is, from another predicated instruction through its psi node),
	// we can try to select the corresponding source value directly
	if (n->pred && v->def && v->def->subtype == NST_PSI) {
		assert(n->subtype == NST_ALU_INST);
		alu_node *an = static_cast<alu_node*>(n);
		node *pn = v->def;
		// FIXME make it more generic ???
		if (pn->src.size() == 6) {
			if (pn->src[3] == n->pred) {
				value* ps = sh.get_pred_sel(an->bc.pred_sel - PRED_SEL_0);
				if (pn->src[4] == ps)
					return pn->src[5];
				else
					return pn->src[2];
			}
		}
	}
	return v;
}
예제 #8
0
void BufferedFile::init()
{
  set_at_eof(false);
  set_count(0);
  set_index(0);
  set_file_pos(0);
}
예제 #9
0
void PythonMpiSimulator::create_PyFuncIO(
        bpy::object py_fn, bpy::object t_in, bpy::object input,
        bpyn::array py_input, bpy::object output, bpy::object index){

    build_dbg("Creating PyFuncIO.");

    string input_signal = bpy::extract<string>(input);
    build_dbg("Input signal: " << input_signal);
    SignalView input_mat = sim->get_signal(input_signal);

    string output_signal = bpy::extract<string>(output);
    build_dbg("Output signal: " << output_signal);
    SignalView output_mat = sim->get_signal(output_signal);

    bool c_t_in = bpy::extract<bool>(t_in);
    dtype* time_pointer = c_t_in ? sim->get_time_pointer() : NULL;

    auto pyfunc = unique_ptr<Operator>(
        new PyFunc(py_fn, time_pointer, input_mat, py_input, output_mat));

    float c_index = bpy::extract<float>(index);
    pyfunc->set_index(c_index);

    sim->add_pyfunc(move(pyfunc));
}
예제 #10
0
파일: util.cpp 프로젝트: aalayach/zebra
Peer::Peer(const string &configFile) {
	config = new Configuration(configFile);
	set_id(get_host_id(config->hostIdType));
	schedulerVec = read_from_file(config->schedulerMemFile);
	set_index(get_self_idx(get_id(), schedulerVec));
	running = true;
	numZHTMsg = 0;
	init_zht_client(config->zhtConfigFile, config->zhtMemFile);
}
예제 #11
0
Node3D::Node3D(int index, int symbol, QColor color, int size)
{
    set_index(index);
    set_coordinates(_random(), _random(), _random());
    set_size(1);
    set_marked(false);
    set_selected(false);
    set_label("");
}
예제 #12
0
void *mlx5_uar_mmap(int idx, int cmd, int page_size, int cmd_fd)
{
	off_t offset;

	offset = 0;
	set_command(cmd, &offset);
	set_index(idx, &offset);

	return mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, cmd_fd, page_size * offset);
}
예제 #13
0
void GCStatInfo::copy_stat(GCStatInfo* stat) {
  set_index(stat->gc_index());
  set_start_time(stat->start_time());
  set_end_time(stat->end_time());
  assert(_usage_array_size == stat->usage_array_size(), "Must have same array size");
  for (int i = 0; i < _usage_array_size; i++) {
    set_before_gc_usage(i, stat->before_gc_usage_for_pool(i));
    set_after_gc_usage(i, stat->after_gc_usage_for_pool(i));
  }
}
예제 #14
0
void ApplicationLauncher::setImportance(int index, int importance)
{
    if (!m_synced) {
        return;
    }

    auto launcher = m_tx.add_launcher();
    launcher->set_index(index);
    launcher->set_importance(static_cast<google::protobuf::uint32>(importance));

    sendLauncherSet(m_tx);
}
예제 #15
0
void PythonMpiSimulator::create_PyFunc(
        bpy::object py_fn, bpy::object t_in, bpy::object index){

    bool c_t_in = bpy::extract<bool>(t_in);
    dtype* time_pointer = c_t_in ? sim->get_time_pointer() : NULL;

    auto pyfunc = unique_ptr<Operator>(new PyFunc(py_fn, time_pointer));

    float c_index = bpy::extract<float>(index);
    pyfunc->set_index(c_index);

    sim->add_pyfunc(move(pyfunc));
}
예제 #16
0
PulseStream &PulseStream::operator =(PulseStream const &s) {
    set_name(s.name());
    set_index(s.index());

    QMutexLocker l(m_data_mutex);
    if (m_sink_index != s.sink_index()) {
        m_sink_index = s.sink_index();
        emit sink_list_idx_changed();
        emit sink_changed();
        emit this_stream_changed();
    }
    return *this;
}
예제 #17
0
void git_repository__cleanup(git_repository *repo)
{
	assert(repo);

	git_cache_clear(&repo->objects);
	git_attr_cache_flush(repo);
	git_submodule_cache_free(repo);

	set_config(repo, NULL);
	set_index(repo, NULL);
	set_odb(repo, NULL);
	set_refdb(repo, NULL);
}
예제 #18
0
int BufferedFile::close()
{
  if (file_pointer() != NULL) { 
    int result = OsFile_close(file_pointer());
    set_file_pointer(0);
    set_file_size(0);
    set_file_pos(0);
    set_index(0);
    set_count(0);
    return result;
  } else {
    return -1;
  }
}
예제 #19
0
bool HDSeed::UpdateIndex(std::string& seed, const std::uint32_t index) const
{
    std::uint32_t oldIndex = 0;
    auto serialized = SerializedSeed(seed, oldIndex);

    if (oldIndex > index) {
        otErr << OT_METHOD << __FUNCTION__
              << ": Index values must always increase." << std::endl;

        return false;
    }

    serialized->set_index(index);

    if (serialized->version() < 2) { serialized->set_version(2); }

    return storage_.Store(*serialized, seed);
}
예제 #20
0
파일: sb1.c 프로젝트: TitaniumBoy/lin
void flush_tlb_all(void)
{
	unsigned long flags;
	unsigned long old_ctx;
	int entry;

	__save_and_cli(flags);
	/* Save old context and create impossible VPN2 value */
	old_ctx = (get_entryhi() & 0xff);
	set_entrylo0(0);
	set_entrylo1(0);
	for (entry = 0; entry < tlb_entries; entry++) {
		set_entryhi(KSEG0 + (PAGE_SIZE << 1) * entry);
		set_index(entry);
		tlb_write_indexed();
	}
	set_entryhi(old_ctx);
	__restore_flags(flags);	
}
예제 #21
0
std::error_code
PollPoller::remove_dispatcher(Dispatcher &dispatcher) {
  assert(dispatchers_.find(dispatcher.get_fd()) != dispatchers_.end());

  int sock = dispatcher.get_fd();

  int vec_idx = dispatcher.get_index();
  if (dispatchers_.size() > 1) {
    fds_[vec_idx] = fds_[fds_.size() - 1];
    auto tgt_disp = dispatchers_[fds_[vec_idx].fd];
    tgt_disp->set_index(vec_idx);
    fds_.pop_back();
  } else {
    fds_.clear();
  }

  dispatchers_.erase(dispatcher.get_fd());
  return LS_OK_ERROR();
}
예제 #22
0
static AstarArray* search(AstarNode *current, int dst, Set *open_set, Set *close_set, void *ud) {
    AstarArray *adjs = NULL;
    if (!current)
        return NULL;

    adjs = get_adjs(ud, current->index);
    int j;
    for (j = 0; j < adjs->len; j++) {
        int i = adjs->arr[j];

        if (i == dst) {
            return path_backtrace(current, dst);
        }

        if (set_find(close_set, i) != -1)
            continue;
        int new_g = gscore(ud, current->index, i) + current->g;

        int index;
        if ((index = set_find(open_set, i)) != -1) {
            AstarNode *node = set_index(open_set, index);
            if (node->g < new_g) {
                continue;
            }
            node->g = new_g;
            node->parent = current;
            set_bubble(open_set, index);
        } else {
            AstarNode *node = create_node(ud, i, dst, current);
            set_insert(open_set, node);
        }
    }
    array_release(&adjs);
    int x = current->index % 30;
    int y = current->index / 30;
    printf("current is %d %d\n",x,y );
    fflush(stdout);
    set_push(close_set, current);
    AstarNode *next = set_pop(open_set);
    return search(next, dst, open_set, close_set, ud);
}
예제 #23
0
파일: mlx5.c 프로젝트: Cai900205/test
static int mlx5_alloc_context(struct verbs_device *vdev,
			      struct ibv_context *ctx, int cmd_fd)
{
	struct mlx5_context	       *context;
	struct mlx5_alloc_ucontext	req;
	struct mlx5_alloc_ucontext_resp resp;
	struct ibv_device		*ibdev = &vdev->device;
	struct verbs_context *verbs_ctx = verbs_get_ctx(ctx);
	int	i;
	int	page_size = to_mdev(ibdev)->page_size;
	int	tot_uuars;
	int	low_lat_uuars;
	int 	gross_uuars;
	int	j;
	off_t	offset;

	mlx5_single_threaded = single_threaded_app();

	context = to_mctx(ctx);
	context->ibv_ctx.cmd_fd = cmd_fd;

	memset(&resp, 0, sizeof(resp));
	open_debug_file(context);
	set_debug_mask();
	set_freeze_on_error();
	if (gethostname(context->hostname, sizeof(context->hostname)))
		strcpy(context->hostname, "host_unknown");

	tot_uuars = get_total_uuars();
	if (tot_uuars <= 0) {
		if (tot_uuars == 0)
			errno = EINVAL;
		else
			errno = -tot_uuars;
		goto err_free;
	}

	gross_uuars = tot_uuars / MLX5_NUM_UUARS_PER_PAGE * 4;
	context->bfs = calloc(gross_uuars, sizeof *context->bfs);
	if (!context->bfs) {
		errno = ENOMEM;
		goto err_free;
	}

	low_lat_uuars = get_num_low_lat_uuars();
	if (low_lat_uuars < 0) {
		errno = ENOMEM;
		goto err_free_bf;
	}

	if (low_lat_uuars > tot_uuars - 1) {
		errno = ENOMEM;
		goto err_free_bf;
	}

	memset(&req, 0, sizeof(req));
	req.total_num_uuars = tot_uuars;
	req.num_low_latency_uuars = low_lat_uuars;
	if (ibv_cmd_get_context(&context->ibv_ctx, &req.ibv_req, sizeof req,
				&resp.ibv_resp, sizeof resp))
		goto err_free_bf;

	context->max_num_qps		= resp.qp_tab_size;
	context->bf_reg_size		= resp.bf_reg_size;
	context->tot_uuars		= resp.tot_uuars;
	context->low_lat_uuars		= low_lat_uuars;
	context->cache_line_size	= resp.cache_line_size;
	context->max_sq_desc_sz = resp.max_sq_desc_sz;
	context->max_rq_desc_sz = resp.max_rq_desc_sz;
	context->max_send_wqebb	= resp.max_send_wqebb;
	context->num_ports	= resp.num_ports;
	context->max_recv_wr	= resp.max_recv_wr;
	context->max_srq_recv_wr = resp.max_srq_recv_wr;
	context->max_desc_sz_sq_dc = resp.max_desc_sz_sq_dc;
	context->atomic_sizes_dc = resp.atomic_sizes_dc;
	pthread_mutex_init(&context->rsc_table_mutex, NULL);
	pthread_mutex_init(&context->srq_table_mutex, NULL);
	for (i = 0; i < MLX5_QP_TABLE_SIZE; ++i)
		context->rsc_table[i].refcnt = 0;

	context->db_list = NULL;

	pthread_mutex_init(&context->db_list_mutex, NULL);


	for (i = 0; i < resp.tot_uuars / MLX5_NUM_UUARS_PER_PAGE; ++i) {
		offset = 0;
		set_command(MLX5_MMAP_GET_REGULAR_PAGES_CMD, &offset);
		set_index(i, &offset);
		context->uar[i] = mmap(NULL, to_mdev(ibdev)->page_size, PROT_WRITE,
				       MAP_SHARED, cmd_fd,
				       page_size * offset);
		if (context->uar[i] == MAP_FAILED) {
			context->uar[i] = NULL;
			goto err_free_bf;
		}
	}

	for (j = 0; j < gross_uuars; ++j) {
		context->bfs[j].reg = context->uar[j / 4] +
			MLX5_BF_OFFSET + (j % 4) * context->bf_reg_size;
		context->bfs[j].need_lock = need_uuar_lock(context, j);
		mlx5_spinlock_init(&context->bfs[j].lock);
		context->bfs[j].offset = 0;
		if (j)
			context->bfs[j].buf_size = context->bf_reg_size / 2;

		context->bfs[j].uuarn = j;
	}

	mlx5_spinlock_init(&context->lock32);

	context->prefer_bf = get_always_bf();
	context->shut_up_bf = get_shut_up_bf();
	mlx5_read_env(ibdev, context);

	mlx5_spinlock_init(&context->hugetlb_lock);
	INIT_LIST_HEAD(&context->hugetlb_list);

	pthread_mutex_init(&context->task_mutex, NULL);

	ctx->ops = mlx5_ctx_ops;
	set_extended(verbs_ctx);
	set_experimental(ctx);

	return 0;

err_free_bf:
	free(context->bfs);

err_free:
	for (i = 0; i < MLX5_MAX_UAR_PAGES; ++i) {
		if (context->uar[i])
			munmap(context->uar[i], page_size);
	}
	close_debug_file(context);
	return errno;
}
예제 #24
0
파일: r92.c 프로젝트: adriancuzman/nbis
/* t_largest_small_angle_cnt */
int r92(real *angles, int *core_x__, int *core_y__,
         int *r92class)
{
    /* System generated locals */
    int i_1;
    real r_1;

    /* Local variables */
    static int largest_small_angle_cnt__, tick;
    static real rask, ratk;
    static int col_left__;
    static real abs_sec_diff_bot__;
    static int tifx;
    static real ratx, abs_sec_diff_top__;
    static int col_check__;
    static int tickx, row_check__;
    static real raskx;
    static int col_right__;
    static real ratkx;
    static int not_core_flag__;
    static int jc;
    static real hk;
    static int jl, kk;
    static real ud;
    static int ir, kt;
    static real ul;
    static int sr;
    static real ts;
    static int sw;
    static real ut;
    static int cnt_large_for_arch__, sw1, sw2, sw4, row_bottom__, jlf, 
	    row, col, sww, jrt, clx, cnt_angle_large__, ktx;
    static real psl, psr;
    static int row_bot__;
    static real psp, trf;
    static int cnt_angle_small__, row_top__, row_dir_low__;

    /* Parameter adjustments */
    angles -= 33;

    /* Function Body */
    param_real__1.rk1 = (float)111.;
    param_real__1.rk2 = (float)45.;
    param_real__1.rk3 = (float)0.;
    param_int__1.rk4 = 8;
    param_real__1.rk5 = (float)73.;
    param_real__1.rk6 = (float)76.;
    param_real__1.rk7 = (float)176.;
    param_int__1.rk8 = 3;
    param_int__1.rk9 = 29;
    param_int__1.rk10 = 1;
    param_int__1.rk11 = 30;
    param_int__1.rk12 = 4;
    param_real__1.rk13 = (float)50.;
    param_real__1.rk14 = (float)100.;
    param_real__1.rk15 = (float)75.;
    param_int__1.rk16 = 3;
    param_int__1.rk17 = 9;
    param_int__1.rk18 = 3;
    param_real__1.rk19 = (float)465.;
    param_real__1.rk20 = (float)379.;
    param_real__1.rk21 = (float)379.;
    param_real__1.rk22 = (float)210.;
    param_real__1.rk23 = (float)90.;
    param_real__1.rk24 = (float)7.;
    param_int__1.rk25 = 3;
    param_int__1.rk26 = 4;
    param_int__1.rk27 = 3;
    param_int__1.rk28 = 10;
    param_int__1.rk29 = 2;
    param_real__1.rk30 = (float)76.;
    param_real__1.rk31 = (float)45.;
    param_real__1.rk32 = (float)30.;
    param_real__1.rk33 = (float)180.;
    param_real__1.rk34 = (float)0.;
    param_int__1.rk35 = 2;
/* L1: */
    k_table__1.k = 0;
    row = param_int__1.rk10;
    *core_x__ = (float)200.;
    *core_y__ = (float)200.;
    hk = (param_real__1.rk23 - param_real__1.rk31) / (float)34.9128;
    row_bottom__ = param_int__1.rk11;
    row_dir_low__ = 30;
    build_k_table(&angles[33], &row, &row_bottom__, &row_dir_low__);
/* L83: */
    clx = 0;
    sw4 = 0;
    sww = 0;
    trf = (float)0.;
L84:
    if (k_table__1.k <= 0) {
	goto L155;
    }
/* L85: */
    if (k_table__1.t_core_cand__[k_table__1.k - 1] > 0) {
	clx = 1;
	sw1 = 0;
	goto L88;
    }
L86:
    --k_table__1.k;
    goto L84;
L88:
    col_check__ = k_table__1.t_col__[k_table__1.k - 1];
    row_check__ = k_table__1.t_row__[k_table__1.k - 1];
    largest_small_angle_cnt__ = 0;
    cnt_large_for_arch__ = 0;
    cnt_angle_small__ = 0;
    row_top__ = row_check__ - 3;
    col_left__ = col_check__ - 4;
    col_right__ = col_check__ + 4;
    row_bot__ = row_check__ + 2;
    ir = 0;
    sr = 0;
    cnt_angle_large__ = 0;
    sw2 = 0;
    row = row_bot__;
L91:
    if (row > 29) {
	goto L93;
    }
/* L92: */
    if (row <= row_dir_low__) {
	goto L94;
    }
L93:
    --row;
    goto L91;
L94:
    col = col_right__;
    sw = 0;
    psp = (float)99.;
L95:
    if (col < 29) {
	goto L128;
    }
L96:
    if (col > col_left__) {
/* L97: */
	if (col > 1) {
/* L98: */
	    --col;
	    goto L95;
	}
    }
/* L99: */
    if (sw2 > 0 || row > row_check__) {
	goto L101;
    }
    if (ir > 0) {
	abs_sec_diff_bot__ = sr * (float)10. / ir;
	ir = 0;
	sr = 0;
    }
    sw2 = 1;
L101:
    if (row <= 1) {
	is_it_a_core(&ir, &sr, &abs_sec_diff_top__, &abs_sec_diff_bot__, &
		ratk, &rask, &ratkx, &raskx, &ratx, &tickx, &
		cnt_angle_large__, &largest_small_angle_cnt__, &
		cnt_large_for_arch__, &sw1, &sw4, &tifx, &ktx, &
		not_core_flag__);
	goto L126;
    }
/* L102: */
    if (cnt_angle_small__ > largest_small_angle_cnt__) {
	largest_small_angle_cnt__ = cnt_angle_small__;
    }
/* L104: */
    if (row <= row_top__) {
	is_it_a_core(&ir, &sr, &abs_sec_diff_top__, &abs_sec_diff_bot__, &
		ratk, &rask, &ratkx, &raskx, &ratx, &tickx, &
		cnt_angle_large__, &largest_small_angle_cnt__, &
		cnt_large_for_arch__, &sw1, &sw4, &tifx, &ktx, &
		not_core_flag__);
	goto L126;
    }
/* L106: */
    cnt_angle_small__ = 0;
    --row;
    goto L94;
L126:
    if (sw1 > 0) {
/* L173: */
	if (not_core_flag__ > 0) {
	    goto L176;
	} else {
	    goto L174;
	}
    }
/* L127: */
    if (not_core_flag__ <= 0) {
	goto L197;
    } else {
	goto L86;
    }
L128:
    if (angles[row + ((col + 1) << 5)] < (float)99.) {
	psp = angles[row + ((col + 1) << 5)];
    }
    if (psp >= (float)99.) {
	goto L96;
    }
/* L129: */
    if (angles[row + (col << 5)] >= (float)99.) {
	goto L96;
    }
/* L130: */
    if (sw2 <= 0) {
	goto L144;
    }
/* L131: */
    if (col <= col_left__) {
	goto L144;
    }
/* L132: */
    if ((r_1 = angles[row + (col << 5)], dabs(r_1)) >= param_real__1.rk30) {
	++cnt_angle_large__;
    }
/* L134: */
    if (col > col_check__) {
	goto L138;
    }
/* L135: */
    if (angles[row + (col << 5)] < -(doublereal)param_real__1.rk32) {
	goto L141;
    }
/* L136: */
    psl = hk * (col_check__ - col) * (float)11.6376 + param_real__1.rk31;
/* L137: */
    if (angles[row + (col << 5)] > psl) {
	goto L141;
    }
    goto L142;
L138:
    if (angles[row + (col << 5)] > param_real__1.rk32) {
	goto L141;
    }
/* L139: */
    psr = hk * (col_check__ + 1 - col) * (float)11.6376 - param_real__1.rk31;
/* L140: */
    if (angles[row + (col << 5)] > psr) {
	goto L142;
    }
L141:
    ++cnt_large_for_arch__;
L142:
    if ((r_1 = angles[row + (col << 5)], dabs(r_1)) > param_real__1.rk24) {
	goto L144;
    }
    ++cnt_angle_small__;
L144:
    ut = psp - angles[row + (col << 5)];
/* L145: */
    if (ut <= (float)90.) {
	if (ut < (float)-90.) {
	    ut += (float)180.;
	}
    } else {
	ut += (float)-180.;
    }
/* L149: */
    if (sw > 0) {
	goto L151;
    }
    ul = ut;
    sw = 1;
    goto L96;
L151:
    ud = (r_1 = ut - ul, dabs(r_1));
    ul = ut;
/* L152: */
    if (ud > (float)90.) {
	ud = (float)180. - ud;
    }
/* L154: */
    ++ir;
    sr += ud;
    goto L96;
L155:
    if (k_table__1.k_max__ < 2) {
	goto L196;
    }
    trf = (float)0.;
    k_table__1.k = 2;
L157:
    if ((i_1 = k_table__1.t_col__[k_table__1.k - 2] - k_table__1.t_col__[
	    k_table__1.k - 1], abs(i_1)) > 1) {
	goto L159;
    }
/* L158: */
    if (k_table__1.t_row__[k_table__1.k - 1] - k_table__1.t_row__[
	    k_table__1.k - 2] <= 1) {
	goto L162;
    }
L159:
    if (k_table__1.k >= k_table__1.k_max__) {
	goto L176;
    }
/* L160: */
    if (k_table__1.t_row__[k_table__1.k] - k_table__1.t_row__[k_table__1.k - 
	    1] > 1) {
	goto L176;
    }
/* L161: */
    if ((i_1 = k_table__1.t_col__[k_table__1.k] - k_table__1.t_col__[
	    k_table__1.k - 1], abs(i_1)) > 1) {
	goto L176;
    }
L162:
    if (k_table__1.t_sum_ridge_dir_low__[k_table__1.k - 1] < 
	    param_real__1.rk13) {
	goto L176;
    }
/* L163: */
    if (k_table__1.t_sum_ridge_dir_high__[k_table__1.k - 1] < 
	    param_real__1.rk14) {
	goto L176;
    }
    col = k_table__1.t_col__[k_table__1.k - 1];
    jlf = col - param_int__1.rk12;
    jrt = col + 1 + param_int__1.rk12;
/* L165: */
    if (jlf < 1) {
	goto L176;
    }
/* L166: */
    if (jrt > 29) {
	goto L176;
    }
    col = jlf;
    row = k_table__1.t_row__[k_table__1.k - 1];
    ts = (float)0.;
L168:
    if (angles[row + (col << 5)] >= (float)99.) {
	goto L176;
    }
    ts += (r_1 = angles[row + (col << 5)], dabs(r_1));
/* L170: */
    if (col < jrt) {
	++col;
	goto L168;
    }
/* L172: */
    k_table__1.tsa[k_table__1.k - 1] = ts;
    sw1 = 1;
    if (k_table__1.t_not_core_flag__[k_table__1.k - 1] > 0) {
	goto L176;
    }
    if (k_table__1.t_core_cand__[k_table__1.k - 1] <= 0) {
	goto L88;
    }
L174:
    if (ts >= trf) {
	trf = ts;
	kt = k_table__1.k;
    }
L176:
    if (k_table__1.k < k_table__1.k_max__) {
/* L177: */
	++k_table__1.k;
	goto L157;
    }
/* L178: */
    if (trf == (float)0.) {
	goto L196;
    }
/* L179: */
    set_index(&col_left__, &col_right__, &row_bot__, &row, &jc, &
	    row_dir_low__, &col, &kt, &angles[33]);
/* L194: */
    if (jc <= param_int__1.rk18) {
	*r92class = 2;
	col_check__ = k_table__1.t_col__[kt - 1];
	row_check__ = k_table__1.t_row__[kt - 1];
	goto L206;
    }
L196:
    *r92class = 3;
    kt = 0;
    goto L206;
L197:
    if (k_table__1.k + 2 > k_table__1.k_max__) {
	goto L205;
    }
/* L198: */
    if ((i_1 = k_table__1.t_col__[k_table__1.k] - k_table__1.t_col__[
	    k_table__1.k - 1], abs(i_1)) > 1) {
	goto L205;
    }
/* L199: */
    if ((i_1 = k_table__1.t_col__[k_table__1.k + 1] - k_table__1.t_col__[
	    k_table__1.k], abs(i_1)) > 1) {
	goto L205;
    }
/* L200: */
    if (k_table__1.t_row__[k_table__1.k] - k_table__1.t_row__[k_table__1.k - 
	    1] > 1) {
	goto L205;
    }
/* L201: */
    if (k_table__1.t_row__[k_table__1.k + 1] - k_table__1.t_row__[
	    k_table__1.k] > 1) {
	goto L205;
    }
/* L202: */
    if (k_table__1.t_sum_ad__[k_table__1.k] >= param_real__1.rk33) {
	goto L205;
    }
/* L203: */
    if (k_table__1.t_sum_ad__[k_table__1.k + 1] >= param_real__1.rk33) {
	goto L205;
    }
/* L204: */
    k_table__1.k = 0;
    goto L155;
L205:
    *r92class = 1;
    kt = k_table__1.k;
    trf = k_table__1.t_sum_dir_diff__[k_table__1.k - 1];
L206:
    compute_core(core_x__, core_y__, r92class, &clx, &ktx, &kt, &ratk, &
	    col_check__, &row_check__, &row, &col, &jl, &ratx, &rask, &ratkx, 
	    &raskx, &tick, &tickx, &tifx, &angles[33]);
/* L233: */
    if (kt <= 0) {
	goto L300;
    }
/* L234: */
    kk = kt;
L235:
    if (kk <= 1) {
	goto L300;
    }
/* L236: */
    if (k_table__1.t_row__[kt - 1] - k_table__1.t_row__[kk - 1] > 
	    param_int__1.rk35) {
	goto L300;
    }
/* L237: */
    if (k_table__1.t_row__[kk - 1] - k_table__1.t_row__[kk - 2] > 1) {
	goto L300;
    }
/* L238: */
    if ((i_1 = k_table__1.t_col__[kk - 1] - k_table__1.t_col__[kk - 2], abs(
	    i_1)) > 1) {
	ratk = (float)600.;
	goto L300;
    } else {
	--kk;
	goto L235;
    }
L300:
    return 0;
} /* r92_ */
예제 #25
0
void git_repository_set_index(git_repository *repo, git_index *index)
{
	assert(repo && index);
	set_index(repo, index);
}
EAP_FUNC_EXPORT eap_status_e eap_plugin_server_message_if_c::process_message(eap_process_tlv_message_data_c * const message)
{
	// Parses message data composed of Attribute-Value Pairs.

	EAP_TRACE_DATA_DEBUG(
		m_am_tools,
		EAP_TRACE_FLAGS_NEVER,
		(EAPL("eap_plugin_server_message_if_c::process_message()"),
		message->get_message_data(),
		message->get_message_data_length()));

	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eap_plugin_server_message_if_c::process_message()");

	eap_array_c<eap_tlv_header_c> parameters(m_am_tools);

	eap_status_e status = message->parse_message_data(&parameters);
	if (status != eap_status_ok)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

		(void) send_error_message(
			status,
			eap_tlv_message_type_function_none);

		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	if (parameters.get_object_count() == 0)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

		status = eap_status_illegal_parameter;

		(void) send_error_message(
			status,
			eap_tlv_message_type_function_none);

		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	const eap_tlv_header_c * const function_header = parameters.get_object(eap_message_payload_index_function);
	if (function_header == 0
		|| (function_header->get_type() != eap_tlv_message_type_error
			&& function_header->get_type() != eap_tlv_message_type_function))
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

		status = eap_status_illegal_parameter;

		(void) send_error_message(
			status,
			eap_tlv_message_type_function_none);

		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	if (function_header->get_type() == eap_tlv_message_type_error)
	{
		status = process_message_type_error(&parameters);
	}
	else // function_header->get_type() == eap_tlv_message_type_function
	{
		eap_tlv_message_type_function_e function(eap_tlv_message_type_function_none);

		status = message->get_parameter_data(function_header, &function);
		if (status != eap_status_ok)
		{
			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

			(void) send_error_message(
				status,
				eap_tlv_message_type_function_none);

			return EAP_STATUS_RETURN(m_am_tools, status);
		}

		EAP_TRACE_DEBUG(
			m_am_tools, 
			TRACE_FLAGS_DEFAULT, 
			(EAPL("eap_plugin_server_message_if_c::process_message(): this = 0x%08x, message=%d=%s\n"),
			this,
			function,
			eap_process_tlv_message_data_c::get_function_string(function)));

		switch(function)
		{
		case eap_tlv_message_type_function_plugin_get_configuration:
			status = get_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_set_configuration:
			status = set_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_copy_configuration:
			status = copy_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_delete_configuration:
			status = delete_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_set_index:
			status = set_index(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_get_type_info:
			status = get_type_info(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_invoke_ui:
			status = invoke_ui(&parameters);
			break;
		default:
			EAP_TRACE_ERROR(
				m_am_tools,
				TRACE_FLAGS_DEFAULT,
				(EAPL("ERROR: process_data(): unknown function %d.\n"),
				 function));

			status = eap_status_illegal_parameter;

			EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
		};

		if (status != eap_status_ok
			&& status != eap_status_success
			&& status != eap_status_pending_request
			&& status != eap_status_completed_request
			&& status != eap_status_drop_packet_quietly)
		{
			(void) send_error_message(
				status,
				function);
		}
	}

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
	return EAP_STATUS_RETURN(m_am_tools, status);
}
예제 #27
0
 void set_state(Node_State ns) {
   set_index((uint)ns);
 }
예제 #28
0
/*
  Note for posterity:
  I made a mistake when I first wrote this, I set size of the histograms to 
  be 255 (i.e 0xff) bytes each, however a byte can take on 256 (i.e 0x100) possible
  values. This caused a subtle bug, the function would work so long as the byte 0xff didn't
  appear in the input, but if it did then memory out of bounds would be written (generally
  writing to hist_n[0xff] would write to hist_n+1[0] instead). It took me a while
  to realize what was going on.
*/
uint64_t *radix_sort_u64(uint64_t *in, size_t sz){
  uint64_t *hist = alloca(8 * 0x100 * sizeof(uint64_t));
  uint64_t *hist0 = hist;
  uint64_t *hist1 = hist0 + 0x100;
  uint64_t *hist2 = hist1 + 0x100;
  uint64_t *hist3 = hist2 + 0x100;
  uint64_t *hist4 = hist3 + 0x100;
  uint64_t *hist5 = hist4 + 0x100;
  uint64_t *hist6 = hist5 + 0x100;
  uint64_t *hist7 = hist6 + 0x100;
  uint64_t total = 0, sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0;
  uint64_t sum4 = 0, sum5 = 0, sum6 = 0 , sum7 = 0;
  size_t i;
  memset(hist, '\0', 8*0xff*sizeof(uint64_t));
  for(i=0;i<sz;i++){
    hist0[get_byte(in[i], 0)]++;
    hist1[get_byte(in[i], 1)]++;
    hist2[get_byte(in[i], 2)]++;
    hist3[get_byte(in[i], 3)]++;
    hist4[get_byte(in[i], 4)]++;
    hist5[get_byte(in[i], 5)]++;
    hist6[get_byte(in[i], 6)]++;
    hist7[get_byte(in[i], 7)]++;
  }  
#define set_index(byte)                         \
  total = CAT(hist,byte)[i] + CAT(sum,byte);    \
  CAT(hist,byte)[i] = CAT(sum, byte);           \
  CAT(sum, byte) = total;
  
  for(i=0;i<0x100;i++){
    set_index(0);
    set_index(1);
    set_index(2);
    set_index(3);
    set_index(4);
    set_index(5);
    set_index(6);
    set_index(7);
  }
  
  uint64_t *temp = zmalloc(sz*sizeof(uint64_t));
  uint64_t *a = in, *b = temp;
  size_t pos = 0;
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 0);
    b[hist0[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 1);
    b[hist1[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 2);
    b[hist2[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 3);
    b[hist3[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 4);
    b[hist4[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 5);
    b[hist5[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 6);
    b[hist6[pos]++] = a[i];
  }
  SWAP(a, b);
  for(i=0;i<sz;i++){
    pos = get_byte(a[i], 7);
    b[hist7[pos]++] = a[i];
  }
  SWAP(a, b);
  free(temp);
  return in;
}
예제 #29
0
void * motor_thread(void * arg)
{
	int iret;
	int a_bound=0,b_bound=0;
	unsigned char low_gpio[4]={0,0,0,0};
	unsigned char (*ptr)[4], *p;
	unsigned int	a_step_delay=0, b_step_delay=0;
	ptr = step_data;
	while(run_motor_thread)
	{

		set_step_motor(low_gpio,a_motor.gpio);
		set_step_motor( low_gpio,b_motor.gpio);
		iret = pthread_cond_wait(&motor_update,&motion_mutex);
		autostop_counter = 0;
		
		while ((a_motor.state != MOTOR_STOP || b_motor.state != MOTOR_STOP) && (autostop_counter < AUTOSTOP_COUNTER))
		{
			if(a_motor.state != MOTOR_STOP && a_step_delay ==0)
			{	
			
				if(is_boundary(a_motor.gpio[4]))
				{	
``````````````````````````````a_bound +=a_motor.state;
					if(a_bound > BOUNDARY_DETECT_NUM || a_bound < -BOUNDARY_DETECT_NUM)
					{
						a_motor.last_bound = a_motor.state;
						a_motor.state = MOTOR_STOP;
						a_bound = 0;
						printf("A motor boundary\n");
					}

				}
				
				set_index(&(a_motor.data_index), a_motor.state);
				set_index(&(a_motor.data_index), a_motor.state);

				p = *( ptr+ a_motor.data_index);
				set_step_motor(p,a_motor.gpio);				
			
				a_step_delay = a_motor.step_delay;
			}
			
			if(b_motor.state != MOTOR_STOP && b_step_delay == 0)
			{
				if(is_boundary(b_motor.gpio[4]))
				{
b_bound +=b_motor.state;
					if(b_bound > BOUNDARY_DETECT_NUM || b_bound < -BOUNDARY_DETECT_NUM)
					{
						b_motor.last_bound = b_motor.state;
						b_motor.state = MOTOR_STOP;
						b_bound =0;
						printf("B motor boundary\n");
					}
				}
				set_index(&(b_motor.data_index), b_motor.state);
				p=*(ptr+b_motor.data_index);
				set_step_motor( p,b_motor.gpio);				
				
				b_step_delay = b_motor.step_delay;
			}
			
			exit_motion:
				usleep(QUATUM_DLAY_STEP_MOTOR);
				autostop_counter++;
				if (autostop_counter >= AUTOSTOP_COUNTER)
				{

				}
				if(a_step_delay)
					a_step_delay--;
				if(b_step_delay)
					b_step_delay--;
		}
	}

	pthread_exit(NULL);
}