Exemplo n.º 1
0
 static inline void f(uint32_t *a, uint32_t *b) {
     switch (state) {
     case 1:
         a[i % 5] += ((a[(3 + i) % 5] & (a[(2 + i) % 5] ^ a[(1 + i) % 5])) ^ a[(1 + i) % 5]) + b[i] + 0x5a827999 + rol(a[(4 + i) % 5], 5);
         a[(3 + i) % 5] = rol(a[(3 + i) % 5], 30);
         break;
     case 2:
         b[i] = blk(b, i);
         a[(1 + i) % 5] += ((a[(4 + i) % 5] & (a[(3 + i) % 5] ^ a[(2 + i) % 5])) ^ a[(2 + i) % 5]) + b[i] + 0x5a827999 + rol(a[(5 + i) % 5], 5);
         a[(4 + i) % 5] = rol(a[(4 + i) % 5], 30);
         break;
     case 3:
         b[(i + 4) % 16] = blk(b, (i + 4) % 16);
         a[i % 5] += (a[(3 + i) % 5] ^ a[(2 + i) % 5] ^ a[(1 + i) % 5]) + b[(i + 4) % 16] + 0x6ed9eba1 + rol(a[(4 + i) % 5], 5);
         a[(3 + i) % 5] = rol(a[(3 + i) % 5], 30);
         break;
     case 4:
         b[(i + 8) % 16] = blk(b, (i + 8) % 16);
         a[i % 5] += (((a[(3 + i) % 5] | a[(2 + i) % 5]) & a[(1 + i) % 5]) | (a[(3 + i) % 5] & a[(2 + i) % 5])) + b[(i + 8) % 16] + 0x8f1bbcdc + rol(a[(4 + i) % 5], 5);
         a[(3 + i) % 5] = rol(a[(3 + i) % 5], 30);
         break;
     case 5:
         b[(i + 12) % 16] = blk(b, (i + 12) % 16);
         a[i % 5] += (a[(3 + i) % 5] ^ a[(2 + i) % 5] ^ a[(1 + i) % 5]) + b[(i + 12) % 16] + 0xca62c1d6 + rol(a[(4 + i) % 5], 5);
         a[(3 + i) % 5] = rol(a[(3 + i) % 5], 30);
         break;
     case 6:
         b[i] += a[4 - i];
     }
 }
void MOOSAppDocumentation::showInterfaceAndExit()
{
    showTitleSection("INTERFACE");

    if(m_xml_doc == NULL) // loaded if necessary
        loadXML();

    blk("SUBSCRIPTIONS:                                                  ");
    blk("------------------------------------                            ");

    if(m_subscriptions.empty())
        blk("  No subscription.                                            ");

    else
        for(int i = 0 ; i < m_subscriptions.size() ; i++)
            blk(m_subscriptions[i].toString());

    blk("                                                                ");
    blk("PUBLICATIONS:                                                   ");
    blk("------------------------------------                            ");

    if(m_publications.empty())
        blk("  No publication.                                             ");

    else
        for(int i = 0 ; i < m_publications.size() ; i++)
            blk(m_publications[i].toString());

    blk("                                                                ");

    exit(0);
}
  void MOOSAppDocumentation::loadXML()
  {
    string repository_path = getRepositoryPath();
    string doc_path = repository_path + "/src/app/" + m_moosapp_name + "/" + m_moosapp_name + ".xml";

    // Test file existance with ifstream
    ifstream xmlfile(doc_path.c_str());
    if(!xmlfile)
    {
      red("  ERROR: unable to load " + m_moosapp_name + ".xml documentation file.");
      blk("  Please check file existance at:");
      blk("  " + doc_path + "\n");
      exit(0);
    }

    // Test XML validity
    string item_error = "";
    m_xml_doc = new XMLDocument();
    if(m_xml_doc->LoadFile(doc_path.c_str()) != XML_NO_ERROR || !parseXML(item_error))
    {
      red("  ERROR: unable to load " + m_moosapp_name + ".xml documentation file.");
      if(item_error != "")
        blk("  Unable to read <" + item_error + ">");
      blk("  Please check XML validity at:");
      blk("  " + doc_path + "\n");
      exit(0);
    }
  }
void MOOSAppDocumentation::showExampleConfigAndExit()
{
    showTitleSection("EXAMPLE MOOS CONFIGURATION");

    string repository_path = getRepositoryPath();
    string example_path = repository_path + "/src/app/" + m_moosapp_name + "/" + m_moosapp_name + ".moos";

    // Test file existance with ifstream
    ifstream moosfile(example_path.c_str());
    if(!moosfile || !moosfile.is_open())
    {
        red("  ERROR: unable to load " + m_moosapp_name + ".moos example file.");
        blk("  Please check file existance at:");
        blk("  " + example_path + "\n");
        exit(0);
    }

    // Write .moos configuration file
    string line;
    while(getline(moosfile, line))
        blk(line);

    blk("");
    moosfile.close();
    exit(0);
}
void MOOSAppDocumentation::showTitleSection(string title_section)
{
    blk("                                                                ");
    blu("================================================================");
    blu(("  " + m_moosapp_name + " - " + title_section).c_str());
    blu("================================================================");
    blk("                                                                ");
}
Exemplo n.º 6
0
static INLINE void
blkdump(struct ymempool *mp) {
	int i;
	printf("sz : %d, fbi : %d\n", sz(mp), mp->fbi);
	for (i = 0; i < sz(mp); i++) {
		printf("blk(%d:%p) : i(%d)\n",
		       i, blk(mp, i), blk(mp, i)->i);
	}
}
void MOOSAppDocumentation::showSynopsis()
{
    if(m_xml_doc == NULL) // loaded if necessary
        loadXML();

    blk("SYNOPSIS:                                                       ");
    blk("------------------------------------                            ");
    blk(multiLineMessage(m_synopsis, MESSAGE_LENGTH, "  "));
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
	loginit(NULL);

	if (argc < 4)
		fatal("Expected 3 arguments");

	parseargs(argc, argv);
	rng(&r);

	int w = strtol(argv[1], NULL, 10);
	int h = strtol(argv[2], NULL, 10);
	int d = strtol(argv[3], NULL, 10);
	Lvl *lvl = lvlnew(d, w, h, 0);

	unsigned int x0 = 2, y0 = 2;
	if (randstart) {
		x0 = rnd(1, w-2);
		y0 = rnd(1, h-2);
	}

	mvsinit();

	do{
		init(lvl);
		if (addwater)
			water(lvl);

		Loc loc = (Loc) { x0, y0, 0 };
		Path *p = pathnew(lvl);
		pathbuild(lvl, p, loc);
		pathfree(p);

		morereach(lvl);
		closeunits(lvl);
	}while(closeunreach(lvl) < lvl->w * lvl->h * lvl->d * 0.40);

	stairs(&r, lvl, x0, y0);

	bool foundstart = false;
	for (int x = 0; x < w; x++) {
	for (int y = 0; y < h; y++) {
		if (blk(lvl, x, y, 0)->tile == 'u' || blk(lvl, x, y, 0)->tile == 'U') {
			foundstart = true;
			break;
		}
	}
	}
	assert(foundstart);

	lvlwrite(stdout, lvl);
	lvlfree(lvl);

	return 0;
}
Exemplo n.º 9
0
 void do_generation(Generation* gen) {
   // Skip the youngest generation.
   if (gen->level() == 0) return;
   // Normally, we're interested in pointers to younger generations.
   VerifyCTSpaceClosure blk(_ct, gen->reserved().start());
   gen->space_iterate(&blk, true);
 }
Exemplo n.º 10
0
void CardTableRS::verify() {
  // At present, we only know how to verify the card table RS for
  // generational heaps.
  VerifyCTGenClosure blk(this);
  GenCollectedHeap::heap()->generation_iterate(&blk, false);
  _ct_bs->verify();
}
Exemplo n.º 11
0
size_t Generation::block_size(const HeapWord* p) const {
    GenerationBlockSizeClosure blk(p);
    // Cast away const
    ((Generation*)this)->space_iterate(&blk);
    assert(blk.size > 0, "seems reasonable");
    return blk.size;
}
Exemplo n.º 12
0
void rpcudp::_package_process(const udpaddr& addr,
	int len, shared_memory memory, size_t memory_size)
{
	/*
		要最先发送ack
		*/
	const_memory_block blk(memory);
	blk.size = memory_size;
	packages_analysis sis(blk);
	rpcudp_detail::__slice_head_attacher attacher(sis);


	complete_result job;

	job.user_key = get_slice;
	job.key = 0;

	auto* arg = new _complete_argument(addr, memory);
	job.argument = arg;

	auto wlock = ISU_AUTO_LOCK(_spinlock);
	arg->client = &_get_client(addr);
	wlock.unlock();

	if (attacher.udp_ex != nullptr)
	{
		arg->client->_send_ack(
			addr, attacher.udp_ex->group_id,
			attacher.udp_ex->slice_id);
	}

	_process_port.post(job);
}
Exemplo n.º 13
0
bool Extractor::readSpec()
{
  progress(QString::fromUtf8("Looking for existing spec.txt..."));
  QFile f(findSrc(QString::fromUtf8("spec.txt")));
  if(!f.open(QIODevice::ReadOnly)){
    progress(QString::fromUtf8("spec.txt not found."));
    return false;
  }
  progress(QString::fromUtf8("Found '%1'.").arg(f.fileName()));

  QTextStream fs(&f);
  QString name;
    uint16_t fh;
    qint64 size;
    QByteArray sha1, md5;
  while(1){
    if(fs.atEnd()){
      break;
    }
    fs>>name>>size>>fh>>md5>>sha1;
    if(!name.isNull()){
      BlockId blk(name, size, fh, md5, sha1);
      targets.insert(std::pair<uint16_t, BlockId>(fh, blk));
    }
  }
  progress(QString::fromUtf8("spec.txt found and read."));
  return (targets.size() != 0);
}
Exemplo n.º 14
0
void G1MarkSweep::mark_sweep_phase2() {
  // Now all live objects are marked, compute the new object addresses.

  // It is imperative that we traverse perm_gen LAST. If dead space is
  // allowed a range of dead object may get overwritten by a dead int
  // array. If perm_gen is not traversed last a klassOop may get
  // overwritten. This is fine since it is dead, but if the class has dead
  // instances we have to skip them, and in order to find their size we
  // need the klassOop!
  //
  // It is not required that we traverse spaces in the same order in
  // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
  // tracking expects us to do so. See comment under phase4.

  G1CollectedHeap* g1h = G1CollectedHeap::heap();
  Generation* pg = g1h->perm_gen();

  EventMark m("2 compute new addresses");
  TraceTime tm("phase 2", PrintGC && Verbose, true, gclog_or_tty);
  GenMarkSweep::trace("2");

  FindFirstRegionClosure cl;
  g1h->heap_region_iterate(&cl);
  HeapRegion *r = cl.result();
  CompactibleSpace* sp = r;
  if (r->isHumongous() && oop(r->bottom())->is_gc_marked()) {
    sp = r->next_compaction_space();
  }

  G1PrepareCompactClosure blk(sp);
  g1h->heap_region_iterate(&blk);

  CompactPoint perm_cp(pg, NULL, NULL);
  pg->prepare_for_compaction(&perm_cp);
}
Exemplo n.º 15
0
void
codeblk(int64 addr, int64 size)
{
	LSym *sym;
	int64 eaddr, n;
	uchar *q;

	if(debug['a'])
		Bprint(&bso, "codeblk [%#x,%#x) at offset %#llx\n", addr, addr+size, cpos());

	blk(ctxt->textp, addr, size);

	/* again for printing */
	if(!debug['a'])
		return;

	for(sym = ctxt->textp; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= addr)
			break;
	}

	eaddr = addr + size;
	for(; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= eaddr)
			break;

		if(addr < sym->value) {
			Bprint(&bso, "%-20s %.8llux|", "_", (vlong)addr);
			for(; addr < sym->value; addr++)
				Bprint(&bso, " %.2ux", 0);
			Bprint(&bso, "\n");
		}

		Bprint(&bso, "%.6llux\t%-20s\n", (vlong)addr, sym->name);
		n = sym->size;
		q = sym->p;

		while(n >= 16) {
			Bprint(&bso, "%.6ux\t%-20.16I\n", addr, q);
			addr += 16;
			q += 16;
			n -= 16;
		}
		if(n > 0)
			Bprint(&bso, "%.6ux\t%-20.*I\n", addr, (int)n, q);
		addr += n;
	}

	if(addr < eaddr) {
		Bprint(&bso, "%-20s %.8llux|", "_", (vlong)addr);
		for(; addr < eaddr; addr++)
			Bprint(&bso, " %.2ux", 0);
	}
	Bflush(&bso);
}
Exemplo n.º 16
0
CompactibleSpace* HeapRegion::next_compaction_space() const {
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
  // cast away const-ness
  HeapRegion* r = (HeapRegion*) this;
  NextCompactionHeapRegionClosure blk(r);
  g1h->heap_region_iterate_from(r, &blk);
  return blk.result();
}
Exemplo n.º 17
0
            void
            assembleBlock(size_t ndof, size_t i, size_t j, const Block& b) {
                assert (ndof == 1);  (void) ndof;

                ISTLTypeDetails::ScalarBCRSMatrix::block_type blk(b[0]);

                mat_[i][j] += blk;
            }
Exemplo n.º 18
0
 void do_generation(Generation* gen) {
   // Skip the youngest generation.
   if (GenCollectedHeap::heap()->is_young_gen(gen)) {
     return;
   }
   // Normally, we're interested in pointers to younger generations.
   VerifyCTSpaceClosure blk(_ct, gen->reserved().start());
   gen->space_iterate(&blk, true);
 }
Exemplo n.º 19
0
inline
void
R3(std::uint32_t block[BLOCK_INTS], std::uint32_t v,
    std::uint32_t &w, std::uint32_t x, std::uint32_t y,
        std::uint32_t &z, std::size_t i)
{
    block[i] = blk(block, i);
    z += (((w|x)&y)|(w&x)) + block[i] + 0x8f1bbcdc + rol(v, 5);
    w = rol(w, 30);
}
Exemplo n.º 20
0
inline
void
R4(std::uint32_t block[BLOCK_INTS], std::uint32_t v,
    std::uint32_t &w, std::uint32_t x, std::uint32_t y,
        std::uint32_t &z, std::size_t i)
{
    block[i] = blk(block, i);
    z += (w^x^y) + block[i] + 0xca62c1d6 + rol(v, 5);
    w = rol(w, 30);
}
Exemplo n.º 21
0
void CardTableRS::verify() {
  // At present, we only know how to verify the card table RS for
  // generational heaps.
  VerifyCTGenClosure blk(this);
  CollectedHeap* ch = Universe::heap();

  if (ch->kind() == CollectedHeap::GenCollectedHeap) {
    GenCollectedHeap::heap()->generation_iterate(&blk, false);
    _ct_bs->verify();
    }
  }
Exemplo n.º 22
0
            static void
            assemble(::std::size_t                       ndof,
                     ::std::size_t                       i   ,
                     const Block&                        b   ,
                     ISTLTypeDetails::ScalarBlockVector& vec ) {
                assert (ndof == 1);  (void) ndof;

                ISTLTypeDetails::ScalarBlockVector::block_type blk(b[0]);

                vec[i] += blk;
            }
Exemplo n.º 23
0
static void stairs(Rng *r, Lvl *lvl, unsigned int x0, unsigned int y0)
{
	if (tileinfo(lvl, x0, y0, 0).flags & Twater)
		blk(lvl, x0, y0, 0)->tile = 'U';
	else
		blk(lvl, x0, y0, 0)->tile = 'u';
	setreach(lvl, x0, y0, 0);

	Loc ls[lvl->w * lvl->h * lvl->d];
	int nls = stairlocs(lvl, ls);
	if (nls == 0)
		fatal("No stair locations");

	Loc l = ls[rnd(0, nls - 1)];
	if (tileinfo(lvl, l.x, l.y, l.z).flags & Twater)
		blk(lvl, l.x, l.y, l.z)->tile = 'D';
	else
		blk(lvl, l.x, l.y, l.z)->tile = 'd';
	setreach(lvl, l.x, l.y, l.z);
}
Exemplo n.º 24
0
TEST( shared_blk , compact ) {
  codex::buffer::shared_blk blk(32);
  blk.write_skip( 10 );
  ASSERT_EQ( blk.length() , 10 );
  ASSERT_EQ( blk.space() , 22 );
  blk.read_skip(5);
  ASSERT_EQ( blk.length() , 5 );
  ASSERT_EQ( blk.space() , 22 );
  blk.compact();
  ASSERT_EQ( blk.length() , 5 );
  ASSERT_EQ( blk.space() , 27 );
}
string MOOSAppDocumentation::getRepositoryPath()
{
    // Test if environment value is set
    char* repository_path = getenv(MOOS_IVP_TOUTATIS_PATH);
    if(repository_path == NULL)
    {
        red("  ERROR: unable to read " + string(MOOS_IVP_TOUTATIS_PATH) + " environment value.");
        blk("  Please update your configuration.");
        blk("  For Linux users: add an EXPORT in your ~/.bashrc file. Ex:");
        blk("    export MOOS_IVP_PROJECTNAME_PATH=\"/home/user/moos-ivp-projectname\"\n");
        exit(0);
    }

    // Test if MOOS_IVP_TOUTATIS_PATH is an absolute path
    if(repository_path[0] != '/')
    {
        red("  ERROR: " + string(MOOS_IVP_TOUTATIS_PATH) + " is not an absolute path.");
        blk("  Please update your configuration.");
        blk("  For Linux users: check the EXPORT in your ~/.bashrc file. Ex:");
        blk("    export MOOS_IVP_PROJECTNAME_PATH=\"/home/user/moos-ivp-projectname\"\n");
        exit(0);
    }

    return string(repository_path);
}
  string MOOSAppDocumentation::getRepositoryPath()
  {
    // Test if environment value is set
    char* repository_path = getenv(MOOS_IVP_ENSTABZH_PATH);
    if(repository_path == NULL)
    {
      red("  ERROR: unable to read " + string(MOOS_IVP_ENSTABZH_PATH) + " environment value.");
      blk("  Please update your configuration.");
      blk("  For Linux users: add an EXPORT in your ~/.bashrc file.\n");
      exit(0);
    }

    // Test if MOOS_IVP_ENSTABZH_PATH is an absolute path
    if(repository_path[0] != '/')
    {
      red("  ERROR: " + string(MOOS_IVP_ENSTABZH_PATH) + " is not an absolute path.");
      blk("  Please update your configuration.");
      blk("  For Linux users: check the EXPORT in your ~/.bashrc file.\n");
      exit(0);
    }

    return string(repository_path);
  }
Exemplo n.º 27
0
Arquivo: data.c Projeto: pipul/lab
void
datblk(int32 addr, int32 size)
{
	Sym *sym;
	int32 eaddr;
	uchar *p, *ep;

	if(debug['a'])
		Bprint(&bso, "datblk [%#x,%#x) at offset %#llx\n", addr, addr+size, cpos());

	blk(datap, addr, size);

	/* again for printing */
	if(!debug['a'])
		return;

	for(sym = datap; sym != nil; sym = sym->next)
		if(sym->value >= addr)
			break;

	eaddr = addr + size;
	for(; sym != nil; sym = sym->next) {
		if(sym->value >= eaddr)
			break;
		if(addr < sym->value) {
			Bprint(&bso, "%-20s %.8ux| 00 ...\n", "(pre-pad)", addr);
			addr = sym->value;
		}
		Bprint(&bso, "%-20s %.8ux|", sym->name, (uint)addr);
		p = sym->p;
		ep = p + sym->np;
		while(p < ep)
			Bprint(&bso, " %.2ux", *p++);
		addr += sym->np;
		for(; addr < sym->value+sym->size; addr++)
			Bprint(&bso, " %.2ux", 0);
		Bprint(&bso, "\n");
	}

	if(addr < eaddr)
		Bprint(&bso, "%-20s %.8ux| 00 ...\n", "(post-pad)", (uint)addr);
	Bprint(&bso, "%-20s %.8ux|\n", "", (uint)eaddr);
}
lightmap&
ambient_occlusion_lightmap::generate (world_lightmap_access& data,
                                      const chunk_coordinates& pos,
                                      const surface& s,
                                      lightmap& lightchunk,
                                      unsigned int phase) const
{
    assert(phase < detail_levels_.size());
    trace("for %1%", world_vector(pos - world_chunk_center));

    auto lmi (std::begin(lightchunk));
    for (faces f : s)
    {
        world_coordinates blk (pos * chunk_size + f.pos);

        for (int d (0) ; d < 5; ++d)
        {
            if (f[d])
            {
                const ray_bundle& r (detail_levels_[phase][d]);
                float light_level (recurse(r, r.weight, blk, data));

                if (d < 4)
                    light_level += d * 0.05f;

                light_level = clamp(light_level, 0.0f, 1.0f);
                lmi->ambient = light_level * 15.4f;
                ++lmi;
            }
        }

        if (f[5])
        {
            lmi->ambient = 0;
            ++lmi;
        }
    }
    assert(lmi == std::end(lightchunk));
    trace("done with %1%", world_vector(pos - world_chunk_center));

    return lightchunk;
}
Exemplo n.º 29
0
TEST( shared_blk , read_write ) {
  codex::buffer::shared_blk blk(32);

  // 0 - read(0) - write(0) - size(32)  
  ASSERT_EQ( blk.length()  , 0 );
  ASSERT_EQ( blk.space() , 32 );
  ASSERT_EQ( blk.size() , 32 );

  ASSERT_EQ( blk.read_skip(-1) , 0 );
  ASSERT_EQ( blk.read_skip(1), 0 );

  // 0 - read(0) - write(28) - size(32)  
  ASSERT_EQ( blk.write_skip(-1) , 0 );
  ASSERT_EQ( blk.write_skip(33) , 32 );
  ASSERT_EQ( blk.write_skip(-4) , -4 );
  ASSERT_EQ( blk.length() , 28 );

  // 0 - read(20) - write(28) - size(32)  
  ASSERT_EQ( blk.read_skip( 20 ) , 20 );
  ASSERT_EQ( blk.length() , 8 );
  
  // 0 - read(20) - write(20) - size(32)  
  ASSERT_EQ( blk.write_skip( -10 ) , -8 );
  ASSERT_EQ( blk.length() , 0 );

  // 0 - read(20) - write(28) - size(32)  
  ASSERT_EQ( blk.write_skip( 8 ) , 8 );

  // 0 - read(0) - write(28) - size(32)
  ASSERT_EQ( blk.read_skip( -40 ) , -20 );
  ASSERT_EQ( blk.length() , 28 );

  // 0 - read(28) - write(28) - size(32)
  ASSERT_EQ( blk.read_skip( 40 ) , 28 );
  ASSERT_EQ( blk.length() , 0 );

  // 0 - read(0) - write(0) - size(32)  
  blk.clear();
  ASSERT_EQ( blk.length()  , 0 );
  ASSERT_EQ( blk.space() , 32 );
  ASSERT_EQ( blk.size() , 32 );
}
Exemplo n.º 30
0
        /** @return IndexDetails for a new index on a:1, with the info field populated. */
        IndexDescriptor* addIndexWithInfo() {
            BSONObj indexInfo = BSON( "v" << 1 <<
                                      "key" << BSON( "a" << 1 ) <<
                                      "ns" << _ns <<
                                      "name" << "a_1" );
            int32_t lenWHdr = indexInfo.objsize() + Record::HeaderSize;
            const char* systemIndexes = "unittests.system.indexes";
            DiskLoc infoLoc = allocateSpaceForANewRecord( systemIndexes,
                                                          nsdetails( systemIndexes ),
                                                          lenWHdr,
                                                          false );
            Record* infoRecord = reinterpret_cast<Record*>( getDur().writingPtr( infoLoc.rec(),
                                                                                 lenWHdr ) );
            memcpy( infoRecord->data(), indexInfo.objdata(), indexInfo.objsize() );
            addRecordToRecListInExtent( infoRecord, infoLoc );

            IndexCatalog::IndexBuildBlock blk( collection()->getIndexCatalog(), "a_1", infoLoc );
            blk.success();

            return collection()->getIndexCatalog()->findIndexByName( "a_1" );
        }