本文整理汇总了C++中Addr类的典型用法代码示例。如果您正苦于以下问题:C++ Addr类的具体用法?C++ Addr怎么用?C++ Addr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Addr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
typename Generic_obj_space<SPACE>::Status
Generic_obj_space<SPACE>::v_insert(Phys_addr phys, Addr const &virt, Size size,
unsigned char page_attribs)
{
(void)size;
assert (size.value() == 1);
Entry *c = get_cap(virt.value());
if (!c && !(c = caps_alloc(virt.value())))
return Insert_err_nomem;
assert (size.value() == 1);
if (c->valid())
{
if (c->obj() == phys)
{
if (EXPECT_FALSE(c->rights() == page_attribs))
return Insert_warn_exists;
c->add_rights(page_attribs);
return Insert_warn_attrib_upgrade;
}
else
return Insert_err_exists;
}
Obj::set_entry(virt, c);
c->set(phys, page_attribs);
return Insert_ok;
}
示例2:
bool
Generic_obj_space<SPACE>::v_lookup(Addr const &virt, Phys_addr *phys = 0,
Size *size = 0, unsigned *attribs = 0)
{
if (size) size->set_value(1);
Entry *cap;
if (Optimize_local
&& mem_space() == Mem_space::current_mem_space(current_cpu()))
cap = cap_virt(virt.value());
else
cap = get_cap(virt.value());
if (EXPECT_FALSE(!cap))
{
if (size) size->set_value(Caps_per_page);
return false;
}
if (Optimize_local)
{
Capability c = Mem_layout::read_special_safe((Capability*)cap);
if (phys) *phys = c.obj();
if (c.valid() && attribs) *attribs = c.rights();
return c.valid();
}
else
{
Obj::set_entry(virt, cap);
if (phys) *phys = cap->obj();
if (cap->valid() && attribs) *attribs = cap->rights();
return cap->valid();
}
}
示例3: CPPUNIT_ASSERT_EQUAL
void
TestAddr::defaultConstruction()
{
Addr a;
CPPUNIT_ASSERT_EQUAL( Addr::PortType( 0u ), a.getPort() );
CPPUNIT_ASSERT_EQUAL( Addr::HostType( 0u ), a.getHost() );
}
示例4: max_addr
Addr max_addr()
{
Addr tmp;
std::fill(tmp.begin(), tmp.end()
, (std::numeric_limits<typename Addr::value_type>::max)());
return Addr(tmp);
}
示例5:
void
TestAddr::SetHostStr()
{
Addr a;
bool result = a.setHost( "localhost" );
CPPUNIT_ASSERT( result );
CPPUNIT_ASSERT_EQUAL( std::string( "localhost" ), a.getHostStr() );
}
示例6: sizeof
void Socket::connect(const Addr& addr)
{
int err = ::connect(m_socket, (const struct sockaddr *)&(addr.getAddr()), sizeof (addr.getAddr()));
if(err < 0)
throw ConnectErr(errno);
m_connected = true;
}
示例7: GetRegName
void Cfg::GetRegName(char *buf, Addr nic_addr, int port_no)
{
buf += sprintf(buf, "%s", GetLoadStr(IDS_IPMSG));
if (port_no != IPMSG_DEFAULT_PORT) {
buf += sprintf(buf, "%d", port_no);
}
if (nic_addr.IsEnabled()) {
*buf++ = '_';
nic_addr.ToStr(buf);
}
}
示例8:
std::shared_ptr<Chunk> ChunkList::createChunk(const Addr &addr, Chunk::Type type) {
auto ch1 = _chunks.find(addr.offset());
if (ch1 != _chunks.end()) {
if (ch1->second->type()!=Chunk::Type::UNPARSED)
return nullptr;
}
std::shared_ptr<Chunk> ch;
ch = std::make_shared<Chunk>(addr, type);
_chunks[addr.offset()]=ch;
return ch;
}
示例9: QTreeWidgetItem
// for code lines
InstrItem::InstrItem(InstrView* iv, QTreeWidget* parent,
Addr addr, bool inside,
const QString& code, const QString& cmd,
const QString& args, TraceInstr* instr)
: QTreeWidgetItem(parent)
{
_view = iv;
_addr = addr;
_instr = instr;
_instrCall = 0;
_instrJump = 0;
_inside = inside;
setTextAlignment(0, Qt::AlignRight);
setTextAlignment(1, Qt::AlignRight);
setTextAlignment(2, Qt::AlignRight);
if (args == "...")
setText(0, args);
else
setText(0, addr.pretty());
setText(4, code);
setText(5, cmd);
setText(6, args);
TraceLine* l;
if (instr && (l = instr->line()))
setText(7, l->name());
updateGroup();
updateCost();
}
示例10: qPrintable
FixCallCost::FixCallCost(TracePart* part, FixPool* pool,
TraceFunctionSource* functionSource,
unsigned int line, Addr addr,
TracePartCall* partCall,
SubCost callCount, FixString& s)
{
if (0) qDebug("Got FixCallCost (addr 0x%s, line %d): calls %s",
qPrintable(addr.toString()), line,
qPrintable(callCount.pretty()));
int maxCount = part->eventTypeMapping()->count();
_part = part;
_functionSource = functionSource;
_line = line;
_addr = addr;
_cost = (SubCost*) pool->reserve(sizeof(SubCost) * (maxCount+1));
s.stripSpaces();
int i = 0;
while(i<maxCount) {
if (!s.stripUInt64(_cost[i])) break;
i++;
}
_count = i;
if (!pool->allocateReserved(sizeof(SubCost) * (_count+1) ))
_count = 0;
else
_cost[_count] = callCount;
_nextCostOfPartCall = partCall ? partCall->setFirstFixCallCost(this) : 0;
}
示例11: assert
typename Generic_obj_space<SPACE>::Status
Generic_obj_space<SPACE>::v_insert(Phys_addr phys, Addr const &virt, Size size,
unsigned char page_attribs)
{
(void)size;
assert (size.value() == 1);
Entry *c;
if (Optimize_local
&& mem_space() == Mem_space::current_mem_space(current_cpu()))
{
c = cap_virt(virt.value());
if (!c)
return Insert_err_nomem;
Capability cap;
if (!Mem_layout::read_special_safe((Capability*)c, cap)
&& !caps_alloc(virt.value()))
return Insert_err_nomem;
}
else
{
c = alien_lookup(virt.value());
if (!c && !(c = caps_alloc(virt.value())))
return Insert_err_nomem;
Obj::set_entry(virt, c);
}
if (c->valid())
{
if (c->obj() == phys)
{
if (EXPECT_FALSE(c->rights() == page_attribs))
return Insert_warn_exists;
c->add_rights(page_attribs);
return Insert_warn_attrib_upgrade;
}
else
return Insert_err_exists;
}
c->set(phys, page_attribs);
return Insert_ok;
}
示例12: getFD
int
Socket::send( const char* msg,
size_t len,
const Addr& dest,
int flags,
CheckingType check )
{
if( check == DONT_CHECK )
{
return ::sendto( getFD(), msg,
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
(int)len,
#else
len,
#endif
flags,
(struct sockaddr *)&( dest.getAddr() ),
sizeof( dest.getAddr() ) );
}
else
{
for(;;)
{
int sent = ::sendto( getFD(), msg,
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
(int)len,
#else
len,
#endif
flags,
(struct sockaddr *)&( dest.getAddr() ),
sizeof( dest.getAddr() ) );
if( sent != -1
|| ( errno != EINTR
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
&& errno != WSAEWOULDBLOCK
#else
&& errno != EWOULDBLOCK
#endif
) )
return sent;
}
}
}
示例13: return
T *
Mem_space::user_to_kernel (T const *addr, bool write)
{
Phys_addr phys;
Addr virt = Addr::create((Address) addr);
unsigned attr, error = 0;
Size size;
for (;;)
{
// See if there is a mapping for this address
if (v_lookup (virt, &phys, &size, &attr))
{
// Add offset to frame
phys = phys | virt.offset(size);
// See if we want to write and are not allowed to
// Generic check because INTEL_PTE_WRITE == INTEL_PDE_WRITE
if (!write || (attr & Pt_entry::Writable))
return (T *) Mem_layout::phys_to_pmem (phys.value());
error |= PF_ERR_PRESENT;
}
if (write)
error |= PF_ERR_WRITE;
// If we tried to access user memory of a space other than current_mem_space()
// our Long-IPC partner must do a page-in. This is analogue to IA32
// page-faulting in the IPC window. Set PF_ERR_REMTADDR hint.
// Otherwise we faulted on our own user memory. Set PF_ERR_USERADDR hint.
error |= (dir() == current_pdir() ? PF_ERR_USERADDR : PF_ERR_REMTADDR);
// No mapping or insufficient access rights, raise pagefault.
// Pretend open interrupts, we restore the current state afterwards.
Cpu_lock::Status was_locked = cpu_lock.test();
thread_page_fault (virt.value(), error, 0,
Proc::processor_state() | EFLAGS_IF, 0);
cpu_lock.set (was_locked);
}
}
示例14: if
int
SocketDgram::sharedOpen(const Addr& local, int protocolFamily) {
bool error = false;
if(local == Addr::sapAny) {
if(protocolFamily == PF_INET) {
if(bindport(this->getHandle(), INADDR_ANY, protocolFamily) == -1)
error = true;
}
} else if(OS::bind(this->getHandle(),
reinterpret_cast<sockaddr*> (local.getAddr()),
local.getSize()) == -1)
error = true;
if(error)
this->close();
return error ? -1:0;
}
示例15: do_generate_successor_frame
std::size_t do_generate_successor_frame(net_link& link, const Addr& sucessor_address, boost::uint16_t sucessor_port)
{
successor_frame<Addr>* frame = buffer_cast<successor_frame<Addr>*>(link.send_buffer(sizeof(successor_frame<Addr>)));
frame->type = connection::frame_successor;
typename Addr::bytes_type peer_ip = sucessor_address.to_bytes();
std::memcpy(frame->sucessor_ip, peer_ip.data(), peer_ip.size());
u16(frame->sucessor_port, sucessor_port);
return sizeof(successor_frame<Addr>);
}