当前位置: 首页>>代码示例>>C++>>正文


C++ Addr类代码示例

本文整理汇总了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;
}
开发者ID:MicroTrustRepos,项目名称:microkernel,代码行数:32,代码来源:obj_space-phys.cpp

示例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();
    }
}
开发者ID:ExpressOS,项目名称:third_party-l4re,代码行数:35,代码来源:obj_space-virt.cpp

示例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() );
}
开发者ID:devgg,项目名称:roboZen_examples,代码行数:7,代码来源:addrtest.cpp

示例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);
	}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例5:

void
TestAddr::SetHostStr() 
{
	Addr a;
	bool result = a.setHost( "localhost" );
    CPPUNIT_ASSERT( result );
	CPPUNIT_ASSERT_EQUAL( std::string( "localhost" ), a.getHostStr() );
}
开发者ID:devgg,项目名称:roboZen_examples,代码行数:8,代码来源:addrtest.cpp

示例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;
}
开发者ID:RGB-RSL,项目名称:rgb,代码行数:8,代码来源:Socket.cpp

示例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);
	}
}
开发者ID:glukki,项目名称:ipmsg,代码行数:11,代码来源:cfg.cpp

示例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;
}
开发者ID:abaddon201,项目名称:qzxsqualpel,代码行数:13,代码来源:chunk_list.cpp

示例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();
}
开发者ID:DeepCV,项目名称:kcachegrind,代码行数:33,代码来源:instritem.cpp

示例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;
}
开发者ID:ShermanHuang,项目名称:kdesdk,代码行数:33,代码来源:fixcost.cpp

示例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;
}
开发者ID:ExpressOS,项目名称:third_party-l4re,代码行数:46,代码来源:obj_space-virt.cpp

示例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;
                }
            }
        }
开发者ID:WenbinWang,项目名称:strive3d,代码行数:44,代码来源:socket.cpp

示例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);
    }
}
开发者ID:ExpressOS,项目名称:third_party-l4re,代码行数:43,代码来源:mem_space-user.cpp

示例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;
}
开发者ID:wuhua988,项目名称:icm,代码行数:19,代码来源:SocketDgram.cpp

示例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>);
}
开发者ID:ssiloti,项目名称:Anynet,代码行数:12,代码来源:connection.cpp


注:本文中的Addr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。