Пример #1
0
BOOST_AUTO_TEST_CASE_TEMPLATE(linearize_request, T, tag_types) {
	http::basic_request<T> request("http://www.boost.org");
	// HTTP/1.0
	linearize(request, "GET", 1, 0, std::ostream_iterator<typename net::char_<T>::type>(std::cout));
	// HTTP/1.1
	linearize(request, "GET", 1, 1, std::ostream_iterator<typename net::char_<T>::type>(std::cout));
}
Пример #2
0
Файл: gen.c Проект: Godzil/osXdk
static sNode_t *linearize(sNode_t p, sNode_t *last, sNode_t next) 
{
	if (p && !p->x.visited) 
	{
		if ( optimizelevel>0 ) 
		{
		    switch (generic(p->op)) 
			{
			case CNST: 
			case ADDRG: 
			case ADDRL: 
			case ADDRF:
				p->x.optimized=1;
				p->x.result=p->syms[0];
				p->x.adrmode=p->syms[0]->x.adrmode;
				p->x.name=p->syms[0]->x.name;
				return last;
		    }
		}
		last = linearize(p->kids[0], last, 0);
		last = linearize(p->kids[1], last, 0);
		p->x.visited = 1;
		*last = p;
		last = &p->x.next;
	}
	*last = next;
	return last;
}
Пример #3
0
void drive(int t, int speed, int turn)
{
	motor[frontLeft]  =  linearize(speed + (maxSteer*turn/100));
	motor[backLeft]   = -linearize(speed + (maxSteer*turn/100));
	motor[frontRight] = -linearize(speed - (maxSteer*turn/100));
	motor[backRight]  =  linearize(speed - (maxSteer*turn/100));
	sleep(t);
}
Пример #4
0
uint64_t
copyarray(
    uint64_t *sizes, 
    uint64_t *sel_start, 
    uint64_t *sel_count, 
    int ndim,
    int elem_size,
    int writer_pos,
    char *writer_array,
    char *reader_array)
{
    if(ndim == 1){
	int start = elem_size * (writer_pos + sel_start[ndim-1]);
	int end = (start + (elem_size)*(sel_count[ndim-1]));
	memcpy(reader_array, writer_array + start, end-start);
	return end-start;
    }
    else{
	int end = sel_start[ndim-1] + sel_count[ndim-1];
	int i;
	int amt_copied = 0;
	for(i = sel_start[ndim-1]; i<end; i++){
	    int pos = linearize(sizes, ndim);    
	    pos *=i;    
	    amt_copied += copyarray(sizes, sel_start, sel_count, ndim-1,
				    elem_size, writer_pos+pos, writer_array, 
				    reader_array+amt_copied);
	}
	return amt_copied;
    }
}
Пример #5
0
void compute_cf_segment(lp_grid lpg, long xsi, long ysi, long zsi)
{
    cell ccell;
    btVector3 cell_origin, cpos;
    std::vector<particle*> neighbours;
    float cf_step = lpg.step / lpg.sdf;
    long ixi = xsi*lpg.xss; long txi = std::min((xsi+1)*lpg.xss, lpg.x);
    long iyi = ysi*lpg.yss; long tyi = std::min((ysi+1)*lpg.yss, lpg.y);
    long izi = zsi*lpg.zss; long tzi = std::min((zsi+1)*lpg.zss, lpg.z);
    for (long zi=izi; zi<tzi; zi++)
	for (long yi=iyi; yi<tyi; yi++)
	    for (long xi=ixi; xi<txi; xi++) {
		cell_origin = btVector3(xi*lpg.step, yi*lpg.step, zi*lpg.step);
		all_neighbour_particles(lpg, xi, yi, zi, neighbours);
		// loop over cf sampling points inside ccell
		for (int z_sd=0; z_sd<lpg.sdf; z_sd++)
		    for (int y_sd=0; y_sd<lpg.sdf; y_sd++)
			for (int x_sd=0; x_sd<lpg.sdf; x_sd++) {
			    cpos = btVector3(x_sd, y_sd, z_sd);
			    cpos *= cf_step;
			    cpos += cell_origin;
			    lpg.color_field[linearize(lpg,
						      xi*lpg.sdf + x_sd,
						      yi*lpg.sdf + y_sd,
						      zi*lpg.sdf + z_sd,
						      lpg.sdf)]
				= sum_cf(neighbours, cpos, lpg.step);
			}
	    }
}
Пример #6
0
static void genspill(Symbol r, Node last, Symbol tmp) {
	Node p, q;
	Symbol s;
	unsigned ty;

	debug(fprint(stderr, "(spilling %s to local %s)\n", r->x.name, tmp->x.name));
	debug(fprint(stderr, "(genspill: "));
	debug(dumptree(last));
	debug(fprint(stderr, ")\n"));
	ty = opkind(last->op);
	NEW0(s, FUNC);
	s->sclass = REGISTER;
	s->name = s->x.name = r->x.name;
	s->x.regnode = r->x.regnode;
	q = newnode(ADDRL+P + sizeop(IR->ptrmetric.size), NULL, NULL, s);
	q = newnode(INDIR + ty, q, NULL, NULL);
	p = newnode(ADDRL+P + sizeop(IR->ptrmetric.size), NULL, NULL, tmp);
	p = newnode(ASGN + ty, p, q, NULL);
	p->x.spills = 1;
	rewrite(p);
	prune(p, &q);
	q = last->x.next;
	linearize(p, q);
	for (p = last->x.next; p != q; p = p->x.next) {
		ralloc(p);
		assert(!p->x.listed || !NeedsReg[opindex(p->op)] || !(*IR->x.rmap)(opkind(p->op)));
	}
}
Пример #7
0
	void Linearize(vector<IStm*>& trees, vector<shared_ptr<StmtList>>& result) {
		result.clear();
		for ( int i = 0; i < trees.size(); ++i ) {
			shared_ptr<StmtList> listLin = linearize( trees[i] );
			result.push_back(listLin);
		}
	}
Vector3D* GrapheneLatticeCreator::createAtoms(double bond_length)
{
	
	Vector3D a[2] = {
	Vector3D(2 * bond_length * (1 + cos(M_PI / 3)), 0, 0),
	Vector3D(0, 2 * bond_length * sin(M_PI / 3), 0)
	};

	Vector3D b[4] = {
	Vector3D(0, bond_length * sin(M_PI / 3), 0),
	Vector3D(bond_length * cos(M_PI / 3), 0, 0),
	Vector3D(bond_length * (cos(M_PI / 3) + 1), 0, 0),
	Vector3D(bond_length * (2 * cos(M_PI / 3) + 1), bond_length * sin(M_PI / 3), 0)
	};
	
	Vector3D* atoms = new Vector3D[l * w * c];
	for (size_t i = 0; i < l; ++i)
	{
		for (size_t j = 0; j < w; ++j)
		{
			for (size_t k = 0; k < c; ++k) atoms[linearize(i, j, k)] = b[k] + (double)i * a[0] + (double)j * a[1];
		}
	}

	return atoms;
}
Пример #9
0
 void send_request_impl(string_type const& method,
                        basic_request<Tag> const& request_,
                        body_generator_function_type generator) {
   boost::asio::streambuf request_buffer;
   linearize(
       request_, method, version_major, version_minor,
       std::ostreambuf_iterator<typename char_<Tag>::type>(&request_buffer));
   connection_base::send_request_impl(socket_, method, request_buffer);
   if (generator) {
     string_type chunk;
     while (generator(chunk)) {
       std::copy(chunk.begin(), chunk.end(),
                 std::ostreambuf_iterator<typename char_<Tag>::type>(
                     &request_buffer));
       chunk.clear();
       connection_base::send_request_impl(socket_, method, request_buffer);
     }
   }
   if (timeout_ > 0) {
     timer_.expires_from_now(boost::posix_time::seconds(timeout_));
     timer_.async_wait(boost::bind(&this_type::handle_timeout,
                                   this_type::shared_from_this(),
                                   boost::arg<1>()));
   }
 }
Пример #10
0
int _aflinear(const Aflinear *rq)
{
	Aflinst t;

	t.rq = rq;
	afprintv(rq->verbose, 2, "Linearizing");

	afprintv(rq->verbose, 3, "Opening database");
	if (linopen(&t) < 0)
		return -1;
	afprintv(rq->verbose, 4, "Checking if database is linearized");
	/* exit if db is already linearized */
	if (t.info.optimized) {
		if (afclosedbf(&t.f) < 0)
			return -1;
		if (freelock(t.rq->db) < 0)
			return -1;
		return aferr(AFELINEAR);
	}

	afprintv(rq->verbose, 3, "Performing linearize process");
	if (linearize(&t) < 0)
		return -1;

	afprintv(rq->verbose, 3, "Closing database");
	if (linclose(&t) < 0)
		return -1;

	return 0;
}
Пример #11
0
int main(int argc, char* argv[])
{
	int i;
	int res = -1;
	void* bin;
	size_t binSize;
	void* algo;
	size_t algoSize;

	if(argc != 3)
		return printSyntax();

	if((algo = loadFile(argv[1], &algoSize)) == NULL)
		return EXIT_FAILURE;
	if((bin = loadFile(argv[2], &binSize)) == NULL)
		return EXIT_FAILURE;

	res = linearize(algo, algoSize, bin, binSize);

	// add some padding to force the DFU statemachine play through
	for(i = 0; i < 2048; i++)
		printf("%c", 0xff);

	return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS;
}
Пример #12
0
 void send_request_impl(string_type  /*unused*/const& method,
                        basic_request<Tag> const& request_,
                        body_generator_function_type generator) {
   boost::asio::streambuf request_buffer;
   linearize(
       request_, method, version_major, version_minor,
       std::ostreambuf_iterator<typename char_<Tag>::type>(&request_buffer));
   connection_base::send_request_impl(socket_, method, request_buffer);
   if (generator) {
     string_type chunk;
     while (generator(chunk)) {
       std::copy(chunk.begin(), chunk.end(),
                 std::ostreambuf_iterator<typename char_<Tag>::type>(
                     &request_buffer));
       chunk.clear();
       connection_base::send_request_impl(socket_, method, request_buffer);
     }
   }
   if (timeout_ > 0) {
     timer_.expires_from_now(boost::posix_time::seconds(timeout_));
     auto self = this->shared_from_this();
     timer_.async_wait([=] (boost::system::error_code const &ec) {
         self->handle_timeout(ec);
       });
   }
 }
Пример #13
0
Файл: gen.c Проект: Godzil/osXdk
sNode_t gen(sNode_t p) 
{
	sNode_t head, *last;
	for (last = &head; p; p = p->link)
		last = linearize(p, last, 0);
	for (p = head; p; p = p->x.next) tmpalloc(p);
	return head;
}
Пример #14
0
static void linearize(Node p, Node next) {
	int i;

	for (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++)
		linearize(p->x.kids[i], next);
	relink(next->x.prev, p);
	relink(p, next);
	debug(fprint(stderr, "(listing %x)\n", p));
}
Пример #15
0
TokenList
compPhaseLinear(EmitInfo finfo, TokenList tl)
{
	phStart(PH_Linear);

	tl = linearize(tl);

	phEnd((PhPrFun) toklistPrint, (PhPrFun) 0, (Pointer) tl);
	return tl;
}
Пример #16
0
    bool utvpi_tester::operator()(expr* e) {
        m_todo.reset();
        m_mark.reset();
        m_todo.push_back(e);
        expr* e1, *e2;

        while (!m_todo.empty()) {
            expr* e = m_todo.back();
            m_todo.pop_back();
            if (!m_mark.is_marked(e)) {
                m_mark.mark(e, true);
                if (is_var(e)) {
                    continue;
                }
                if (!is_app(e)) {
                    return false;
                }
                app* ap = to_app(e);
                if (m.is_eq(ap, e1, e2)) {
                    if (!linearize(e1, e2)) {
                        return false;
                    }
                }
                else if (ap->get_family_id() == m.get_basic_family_id()) {
                    continue;
                }
                else if (a.is_le(e, e1, e2) || a.is_ge(e, e2, e1) || 
                    a.is_lt(e, e1, e2) || a.is_gt(e, e2, e1)) {
                    if (!linearize(e1, e2)) {
                        return false;
                    }
                }
                else if (is_uninterp_const(e)) {
                    continue;
                }
                else {
                    return false;
                }
            }
        }
        return true;
    }
Пример #17
0
void accumulate_if(lp_grid lpg, std::vector<terrain_impulse> tis)
{
    for (long tii=0; tii<tis.size(); tii++) {
	btVector3 relative_position = tis[tii].position - lpg.origin;
	float sd_step = lpg.step / lpg.sdf;
	long i = (long) (0.5 + relative_position.getX() / sd_step);
	long j = (long) (0.5 + relative_position.getY() / sd_step);
	long k = (long) (0.5 + relative_position.getZ() / sd_step);
	lpg.impulse_field[linearize(lpg, i, j, k, lpg.sdf)] += tis[tii].impulse;
    }
}
Пример #18
0
asf::location_function *asf::location_function::make_inverse(void)
{
	switch (relationship) {
	case identity: return new location_function_identity();
	case translation: return new location_function_translation(pixel_fm_loc(-apply(image_location(0,0))));
	case scaling: case linear: 
		return new location_function_linear(linearize(image_location(0,0)).inverse());
	default: /* nonlinear--just search */
		return new location_function_inverse_search(this);
	};
	return 0;
}
Пример #19
0
TYPED_TEST(LinearizeTest, LinearizeRequest) {
  http::basic_request<TypeParam> request("http://www.boost.org");
  static char http_1_0_output[] =
      "GET / HTTP/1.0\r\n"
      "Host: www.boost.org\r\n"
      "Accept: */*\r\n"
      "Connection: Close\r\n"
      "\r\n";
  static char http_1_1_output[] =
      "GET / HTTP/1.1\r\n"
      "Host: www.boost.org\r\n"
      "Accept: */*\r\n"
      "Accept-Encoding: identity;q=1.0, *;q=0\r\n"
      "Connection: Close\r\n"
      "\r\n";
  typename http::basic_request<TypeParam>::string_type output_1_0;
  linearize(request, "GET", 1, 0, std::back_inserter(output_1_0));
  EXPECT_EQ(http_1_0_output, output_1_0);
  typename http::basic_request<TypeParam>::string_type output_1_1;
  linearize(request, "GET", 1, 1, std::back_inserter(output_1_1));
  EXPECT_EQ(http_1_1_output, output_1_1);
}
Пример #20
0
TYPED_TEST(LinearizeTest, OverrideHeaders) {
  http::basic_request<TypeParam> request("http://www.boost.org");
  // We can override the defaulted headers and test that here.
  request << net::header("Accept", "");
  static char http_1_0_no_accept_output[] =
      "GET / HTTP/1.0\r\n"
      "Host: www.boost.org\r\n"
      "Connection: Close\r\n"
      "\r\n";
  static char http_1_1_no_accept_output[] =
      "GET / HTTP/1.1\r\n"
      "Host: www.boost.org\r\n"
      "Accept-Encoding: identity;q=1.0, *;q=0\r\n"
      "Connection: Close\r\n"
      "\r\n";
  typename http::basic_request<TypeParam>::string_type output_1_0;
  linearize(request, "GET", 1, 0, std::back_inserter(output_1_0));
  EXPECT_EQ(http_1_0_no_accept_output, output_1_0);
  typename http::basic_request<TypeParam>::string_type output_1_1;
  linearize(request, "GET", 1, 1, std::back_inserter(output_1_1));
  EXPECT_EQ(http_1_1_no_accept_output, output_1_1);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(linearize_request, T, tag_types) {
  http::basic_request<T> request("http://www.boost.org");
  static char http_1_0_output[] =
      "GET / HTTP/1.0\r\n"
      "Host: www.boost.org\r\n"
      "Accept: */*\r\n"
      "Connection: Close\r\n"
      "\r\n";
  static char http_1_1_output[] =
      "GET / HTTP/1.1\r\n"
      "Host: www.boost.org\r\n"
      "Accept: */*\r\n"
      "Accept-Encoding: identity;q=1.0, *;q=0\r\n"
      "Connection: Close\r\n"
      "\r\n";
  typename http::basic_request<T>::string_type output_1_0;
  linearize(request, "GET", 1, 0, std::back_inserter(output_1_0));
  BOOST_CHECK_EQUAL(output_1_0, http_1_0_output);
  typename http::basic_request<T>::string_type output_1_1;
  linearize(request, "GET", 1, 1, std::back_inserter(output_1_1));
  BOOST_CHECK_EQUAL(output_1_1, http_1_1_output);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(linearize_request_override_headers, T,
                              tag_types) {
    http::basic_request<T> request("http://www.boost.org");
    // We can override the defaulted headers and test that here.
    request << net::header("Accept", "");
    static char http_1_0_no_accept_output[] =
        "GET / HTTP/1.0\r\n"
        "Host: www.boost.org\r\n"
        "Connection: Close\r\n"
        "\r\n";
    static char http_1_1_no_accept_output[] =
        "GET / HTTP/1.1\r\n"
        "Host: www.boost.org\r\n"
        "Accept-Encoding: identity;q=1.0, *;q=0\r\n"
        "Connection: Close\r\n"
        "\r\n";
    typename http::basic_request<T>::string_type output_1_0;
    linearize(request, "GET", 1, 0, std::back_inserter(output_1_0));
    BOOST_CHECK_EQUAL(output_1_0, http_1_0_no_accept_output);
    typename http::basic_request<T>::string_type output_1_1;
    linearize(request, "GET", 1, 1, std::back_inserter(output_1_1));
    BOOST_CHECK_EQUAL(output_1_1, http_1_1_no_accept_output);
}
Пример #23
0
local AbSyn
abqParseSrcLines(SrcLineList sll)
{
	AbSyn ab;
	TokenList tl;

	tl = scan(sll);
	tl = linearize(tl);
	ab = parse(&tl);
	ab = abNormal(ab, false);
	ab = macroExpand(ab);
	ab = abNormal(ab, true);

	return ab;
}
bool* GrapheneLatticeCreator::createFixingMap()
{
	bool* atoms = new bool[l * w * c];
	for (size_t i = 0; i < l; ++i)
	{
		for (size_t j = 0; j < w; ++j)
		{
			for (size_t k = 0; k < c; ++k)
			{
				atoms[linearize(i, j, k)] = (i == 0 && k == 0) || (i == l - 1 && k == c - 1);
			}
		}
	}

	return atoms;
}
Пример #25
0
bool ValidateLoc(const xyLoc& loc)
{
	if (loc.y <= -1 || loc.y >= height ||
		loc.x <= -1 || loc.x >= width)
	{
		return false;
	}

	int locCoords = linearize(loc);
	if(map[locCoords] == false) 
	{
		return false;
	}

	return true;
}
Пример #26
0
Node gen(Node forest) {
	int i;
	struct node sentinel;
	Node dummy, p;

	head = forest;
	for (p = forest; p; p = p->link) {
		assert(p->count == 0);
		if (generic(p->op) == CALL)
			docall(p);
		else if (   generic(p->op) == ASGN
		&& generic(p->kids[1]->op) == CALL)
			docall(p->kids[1]);
		else if (generic(p->op) == ARG)
			(*IR->x.doarg)(p);
		rewrite(p);
		p->x.listed = 1;
	}
	for (p = forest; p; p = p->link)
		prune(p, &dummy);
	relink(&sentinel, &sentinel);
	for (p = forest; p; p = p->link)
		linearize(p, &sentinel);
	forest = sentinel.x.next;
	assert(forest);
	sentinel.x.next->x.prev = NULL;
	sentinel.x.prev->x.next = NULL;
	for (p = forest; p; p = p->x.next)
		for (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++) {
			assert(p->x.kids[i]->syms[RX]);
			if (p->x.kids[i]->syms[RX]->temporary) {
				p->x.kids[i]->x.prevuse =
					p->x.kids[i]->syms[RX]->x.lastuse;
				p->x.kids[i]->syms[RX]->x.lastuse = p->x.kids[i];
			}
		}
	for (p = forest; p; p = p->x.next) {
		ralloc(p);
		if (p->x.listed && NeedsReg[opindex(p->op)]
		&& (*IR->x.rmap)(opkind(p->op))) {
			assert(generic(p->op) == CALL || generic(p->op) == LOAD);
			putreg(p->syms[RX]);
		}
	}
	return forest;
}
Пример #27
0
static void genreload(Node p, Symbol tmp, int i) {
	Node q;
	int ty;

	debug(fprint(stderr, "(replacing %x with a reload from %s)\n", p->x.kids[i], tmp->x.name));
	debug(fprint(stderr, "(genreload: "));
	debug(dumptree(p->x.kids[i]));
	debug(fprint(stderr, ")\n"));
	ty = opkind(p->x.kids[i]->op);
	q = newnode(ADDRL+P + sizeop(IR->ptrmetric.size), NULL, NULL, tmp);
	p->x.kids[i] = newnode(INDIR + ty, q, NULL, NULL);
	rewrite(p->x.kids[i]);
	prune(p->x.kids[i], &q);
	reprune(&p->kids[1], reprune(&p->kids[0], 0, i, p), i, p);
	prune(p, &q);
	linearize(p->x.kids[i], p);
}
Пример #28
0
local AbSyn
shexpParse(String txt)
{
	AbSyn ab;
	TokenList tl;
	SrcLineList sll;
	SrcLine srcLine = slineNew(sposNone, 0, txt);

	sll = listList(SrcLine)(1, srcLine);
	tl = scan(sll);
	tl = linearize(tl);
	ab = parse(&tl);
	ab = abNormal(ab, false);
	ab = macroExpand(ab);
	ab = abNormal(ab, true);

	return ab;
}
Пример #29
0
 void send_request_impl(string_type const& method,
                        basic_request<Tag> const& request_,
                        body_generator_function_type generator) {
     boost::asio::streambuf request_buffer;
     linearize(
         request_, method, version_major, version_minor,
         std::ostreambuf_iterator<typename char_<Tag>::type>(&request_buffer));
     connection_base::send_request_impl(socket_, method, request_buffer);
     if (generator) {
         string_type chunk;
         while (generator(chunk)) {
             std::copy(chunk.begin(), chunk.end(),
                       std::ostreambuf_iterator<typename char_<Tag>::type>(
                           &request_buffer));
             chunk.clear();
             connection_base::send_request_impl(socket_, method, request_buffer);
         }
     }
 }
Пример #30
0
TEST(message_test, linearize_request) {
  http::request request("http://www.boost.org");
  // TODO: Actually specify the expected output.
  linearize(request, "GET", 1, 0, std::ostream_iterator<char>(std::cout));
  linearize(request, "GET", 2, 1, std::ostream_iterator<char>(std::cout));
}