本文整理汇总了C++中Extent::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Extent::size方法的具体用法?C++ Extent::size怎么用?C++ Extent::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extent
的用法示例。
在下文中一共展示了Extent::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
/** Returns a list of parts of a single section that have been referenced. The offsets are relative to the start of the
* section. */
ExtentMap
SgAsmGenericSection::get_referenced_extents() const
{
ExtentMap retval;
if (0==get_size())
return retval;
Extent s(get_offset(), get_size());
const ExtentMap &file_extents = get_file()->get_referenced_extents();
for (ExtentMap::const_iterator i=file_extents.begin(); i!=file_extents.end(); i++) {
Extent e = i->first;
if (e.contained_in(s)) {
retval.insert(Extent(e.first()-get_offset(), e.size()));
} else if (e.left_of(s) || e.right_of(s)) {
/*void*/
} else if (e.contains(s)) {
retval.insert(Extent(0, get_size()));
} else if (e.begins_before(s)) {
retval.insert(Extent(0, e.first()+e.size()-get_offset()));
} else if (e.ends_after(s)) {
retval.insert(Extent(e.first()-get_offset(), get_offset()+get_size()-e.first()));
} else {
assert(!"invalid extent overlap category");
abort();
}
}
return retval;
}
示例2: assert
/** Write just the specified regions back to the file */
void
SgAsmGenericSection::unparse(std::ostream &f, const ExtentMap &map) const
{
for (ExtentMap::const_iterator i=map.begin(); i!=map.end(); ++i) {
Extent e = i->first;
assert(e.first()+e.size() <= get_size());
const unsigned char *extent_data;
if (e.first() >= p_data.size()) {
extent_data = NULL;
} else if (e.first() + e.size() > p_data.size()) {
extent_data = &p_data[e.first()];
} else {
extent_data = &p_data[e.first()];
}
if (extent_data)
write(f, e.first(), e.size(), extent_data);
}
}
示例3:
/** Class method comparing two extents. The return value is one of the following letters, depending on how extent A is related
* to extent B:
* C (congruent): A and B are congruent
* L (left): A is left of B
* R (right): A is right of B
* O (outer): A contains B, but A and B are not congruent
* I (inner): A is contained by B, but A and B are not congruent
* B (beginning): A overlaps with the beginning of B but does not contain B
* E (ending): A overlaps with the end of B but does not contain B */
char
ExtentMap::category(const Extent &a, const Extent &b)
{
if (a.relaxed_first()==b.relaxed_first() && a.size()==b.size())
return 'C';
if (a.relaxed_first()+a.size() <= b.relaxed_first())
return 'L';
if (a.relaxed_first() >= b.relaxed_first()+b.size())
return 'R';
if (a.relaxed_first() <= b.relaxed_first() && a.relaxed_first()+a.size() >= b.relaxed_first()+b.size())
return 'O';
if (a.relaxed_first() >= b.relaxed_first() && a.relaxed_first()+a.size() <= b.relaxed_first()+b.size())
return 'I';
if (a.relaxed_first() <= b.relaxed_first()) /*already know a.first+a.size > b.first*/
return 'B';
return 'E';
}
示例4: hp
void
SgAsmGenericFile::shift_extend(SgAsmGenericSection *s, rose_addr_t sa, rose_addr_t sn, AddressSpace space, Elasticity elasticity)
{
ROSE_ASSERT(s!=NULL);
ROSE_ASSERT(s->get_file()==this);
ROSE_ASSERT((space & (ADDRSP_FILE|ADDRSP_MEMORY)) != 0);
const bool debug = false;
static size_t ncalls=0;
char p[256];
if (debug) {
const char *space_s="unknown";
if (space & ADDRSP_FILE) {
space_s = "file";
} else if (space & ADDRSP_MEMORY) {
space_s = "memory";
}
sprintf(p, "SgAsmGenericFile::shift_extend[%" PRIuPTR "]: ", ncalls++);
fprintf(stderr, "%s -- START --\n", p);
fprintf(stderr, "%s S = [%d] \"%s\"\n", p, s->get_id(), s->get_name()->get_string(true).c_str());
fprintf(stderr, "%s %s Sa=0x%08" PRIx64 " (%" PRIu64 "), Sn=0x%08" PRIx64 " (%" PRIu64 ")\n",
p, space_s, sa, sa, sn, sn);
fprintf(stderr, "%s elasticity = %s\n", p, (ELASTIC_NONE==elasticity ? "none" :
ELASTIC_UNREF==elasticity ? "unref" :
ELASTIC_HOLE==elasticity ? "unref+holes" :
"unknown"));
}
/* No-op case */
if (0==sa && 0==sn) {
if (debug) {
fprintf(stderr, "%s No change necessary.\n", p);
fprintf(stderr, "%s -- END --\n", p);
}
return;
}
bool filespace = (space & ADDRSP_FILE)!=0;
bool memspace = (space & ADDRSP_MEMORY)!=0;
rose_addr_t align=1, aligned_sa, aligned_sasn;
SgAsmGenericSectionPtrList neighbors, villagers;
ExtentMap amap; /* address mappings for all extents */
Extent sp;
/* Get a list of all sections that may need to be adjusted. */
SgAsmGenericSectionPtrList all;
switch (elasticity) {
case ELASTIC_NONE:
case ELASTIC_UNREF:
all = filespace ? get_sections() : get_mapped_sections();
break;
case ELASTIC_HOLE:
all = filespace ? get_sections(false) : get_mapped_sections();
break;
}
if (debug) {
fprintf(stderr, "%s Following sections are in 'all' set:\n", p);
for (size_t i=0; i<all.size(); i++) {
Extent ep;
if (filespace) {
ep = all[i]->get_file_extent();
} else {
ROSE_ASSERT(all[i]->is_mapped());
ep = all[i]->get_mapped_preferred_extent();
}
fprintf(stderr, "%s 0x%08" PRIx64 " 0x%08" PRIx64 " 0x%08" PRIx64 " [%d] \"%s\"\n",
p, ep.relaxed_first(), ep.size(), ep.relaxed_first()+ep.size(), all[i]->get_id(),
all[i]->get_name()->get_string(true).c_str());
}
}
for (size_t pass=0; pass<2; pass++) {
if (debug) {
fprintf(stderr, "%s -- %s --\n",
p, 0==pass?"FIRST PASS":"SECOND PASS (after making a larger hole)");
}
/* S offset and size in file or memory address space */
if (filespace) {
sp = s->get_file_extent();
} else if (!memspace || !s->is_mapped()) {
return; /*nothing to do*/
} else {
sp = s->get_mapped_preferred_extent();
}
/* Build address map */
for (size_t i=0; i<all.size(); i++) {
if (filespace) {
amap.insert(all[i]->get_file_extent());
} else {
ROSE_ASSERT(all[i]->is_mapped());
amap.insert(all[i]->get_mapped_preferred_extent());
}
}
if (debug) {
fprintf(stderr, "%s Address map:\n", p);
amap.dump_extents(stderr, (std::string(p)+" ").c_str(), "amap");
fprintf(stderr, "%s Extent of S:\n", p);
//.........这里部分代码省略.........
示例5: printIndex
void printIndex(off64_t offset, Extent &extent) {
cout << offset << "\t" << extent.getTypePtr()->getName() << "\t" << extent.size() << "\n";
}