Пример #1
0
expression modulus(
    const std::shared_ptr< llvm::LLVMContext > &context,
    const std::shared_ptr< ir_builder_t > &ir_builder,
    const expression &left_expr,
    const expression &right_expr
) {
    const expression left = remove_reference( context, ir_builder, left_expr );
    const expression right = remove_reference( context, ir_builder, right_expr );
    return apply_visitor( node::modulus( context, ir_builder, left, right ), left.type(), right.type() );
}
Пример #2
0
 expression const_cast_(
   const std::shared_ptr< llvm::LLVMContext > &context,
   const std::shared_ptr< ir_builder_t > &ir_builder,
   const type cast_to,
   const expression &value
 ) {
   if(
     type_traits::is_reference( value.type() ) ||
     type_traits::is_pointer( value.type() )
   ) {
     if(
       value.type().which() == cast_to.which()
     ) return remove_const_cast( context, ir_builder, cast_to, value );
     else if(
       type_traits::is_reference( value.type() ) &&
       type_traits::is_pointer( cast_to )
     ) {
       const auto dereferenced = remove_reference( context, ir_builder, value );
       return const_cast_( context, ir_builder, cast_to, dereferenced );
     }
     else if(
       type_traits::is_rvalue_reference( value.type() ) &&
       type_traits::is_lvalue_reference( cast_to )
     ) return reference_cast( context, ir_builder, cast_to, value );
   }
   throw exceptions::invalid_cast();
 }
Пример #3
0
int RealmSocket::open(void * arg)
{
    ACE_INET_Addr addr;

    if (peer().get_remote_addr(addr) == -1)
    {
        sLog->outError(LOG_FILTER_AUTHSERVER, "Error %s while opening realm socket!", ACE_OS::strerror(errno));
        return -1;
    }

    _remoteAddress = addr.get_host_addr();
    _remotePort = addr.get_port_number();

    // Register with ACE Reactor
    if (Base::open(arg) == -1)
        return -1;

    if (session_)
        session_->OnAccept();

    // reactor takes care of the socket from now on
    remove_reference();

    return 0;
}
Пример #4
0
int RealmSocket::open(void * arg)
{
    ACE_INET_Addr addr;

    if (peer ().get_remote_addr (addr) == -1)
    {
        sLog.outError ("RealmSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno));
        return -1;
    }

    remote_address_ = addr.get_host_addr();

    // Register with ACE Reactor
    if (Base::open(arg) == -1)
        return -1;

    if (session_ != NULL)
    {
        session_->OnAccept();
    }

    // reactor takes care of the socket from now on
    remove_reference();

    return 0;
}
Пример #5
0
void BitVector::set_to_ones(void)
  {
    _has_count = true;
    _count = 0;
    remove_reference(_block);
    _block = _ones_block;
    add_reference(_block);
  }
Пример #6
0
void BitVector::set_to_zero(void)
  {
    remove_reference(_block);
    _block = _zero_block;
    add_reference(_block);
   _has_count = true;
   _count = 0;
  }
Пример #7
0
int WorldSocket::open (void *a)
{
    ACE_UNUSED_ARG (a);

    // Prevent double call to this func.
    if (m_OutBuffer)
        return -1;

    // This will also prevent the socket from being Updated
    // while we are initializing it.
    m_OutActive = true;

    // Hook for the manager.
    if (sWorldSocketMgr->OnSocketOpen(this) == -1)
        return -1;

    // Allocate the buffer.
    ACE_NEW_RETURN (m_OutBuffer, ACE_Message_Block (m_OutBufferSize), -1);

    // Store peer address.
    ACE_INET_Addr remote_addr;

    if (peer().get_remote_addr(remote_addr) == -1)
    {
        sLog->outError("WorldSocket::open: peer().get_remote_addr errno = %s", ACE_OS::strerror (errno));
        return -1;
    }

    m_Address = remote_addr.get_host_addr();

    // Send startup packet.
    WorldPacket packet (SMSG_AUTH_CHALLENGE, 24);
    packet << uint32(1);                                    // 1...31
    packet << m_Seed;

    BigNumber seed1;
    seed1.SetRand(16 * 8);
    packet.append(seed1.AsByteArray(16), 16);               // new encryption seeds

    BigNumber seed2;
    seed2.SetRand(16 * 8);
    packet.append(seed2.AsByteArray(16), 16);               // new encryption seeds

    if (SendPacket(packet) == -1)
        return -1;

    // Register with ACE Reactor
    if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
    {
        sLog->outError("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno));
        return -1;
    }

    // reactor takes care of the socket from now on
    remove_reference();

    return 0;
}
Пример #8
0
int RealmSocket::close(int) {
	shutdown();

	closing_ = true;

	remove_reference();

	return 0;
}
Пример #9
0
int WorldSocket::close (u_long)
{
    shutdown();

    closing_ = true;

    remove_reference();

    return 0;
}
Пример #10
0
void BitVector::operator=(const BitVector &other)
  {
    if (_block != other._block)
      {
        remove_reference(_block);
        _block = other._block;
        add_reference(_block);
	_has_count = other._has_count;
	_count = other._count;
      }
  }
Пример #11
0
int RASocket::close(int)
{
    if(closing_)
        return -1;
    DEBUG_LOG("RASocket::close");
    shutdown();

    closing_ = true;

    remove_reference();
    return 0;
}
Пример #12
0
void BitVector::read(const char *location)
  {
    _has_count = false;
    _count = 0;
    const char *follow = location;
    suif_assert((*follow == '0') && (follow[1] == 'x'));
    follow += 2;
    bool sign_extend = (*follow == '.');
    while (*follow == '.')
        ++follow;
    const char *end = follow;
    while (*end != 0)
        ++end;
    suif_assert(end > follow);
    remove_reference(_block);
    size_t hex_digits_per_word = sizeof(BitVector::ChunkT) * 2;
    bool infinity_is_one =
            (sign_extend ? ((*follow > '7') || (*follow < '0')) : false);
    size_t word_count =
            ((end - follow) + hex_digits_per_word - 1) / hex_digits_per_word;
    _block = new BitVectorBlock(word_count, infinity_is_one, word_count);
    size_t word_num = word_count;
    if (((end - follow) % hex_digits_per_word) > 0)
      {
        BitVector::ChunkT high_word = (infinity_is_one ? ~0lu : 0lu);
        while (((end - follow) % hex_digits_per_word) > 0)
          {
            unsigned char new_half_byte = convert_from_hex(*follow);
            suif_assert(new_half_byte != 16);
            high_word = (high_word << 4) | new_half_byte;
            ++follow;
          }
        --word_num;
        _block->_data[word_num] = high_word;
      }
    while (follow < end)
      {
        BitVector::ChunkT this_word = 0;
        for (size_t digit_num = 0; digit_num < hex_digits_per_word;
             ++digit_num)
          {
            unsigned char new_half_byte = convert_from_hex(*follow);
            suif_assert(new_half_byte != 16);
            this_word = (this_word << 4) | new_half_byte;
            ++follow;
          }
        --word_num;
        _block->_data[word_num] = this_word;
      }
    assert(follow == end);
    assert(word_num == 0);
    _block->unpad();
  }
void release_notifier_domain(domain_maintainer_t *dm, notifier_domain_t *domain)
{
	if ((!dm) || (!domain)) return;
	
	cds_mutex_lock(&dm->mutex);
	if (remove_reference(&domain->ref)) {
		/* last reference */
		DEBUG_LOG("freeing domain: \'%.*s\'\n", FMT_STR(domain->name));
		remove_notifier_domain(dm, domain);
		destroy_notifier_domain(domain);
	}
	cds_mutex_unlock(&dm->mutex);
}
Пример #14
0
 expression c_style_cast(
   const std::shared_ptr< llvm::LLVMContext > &context,
   const std::shared_ptr< ir_builder_t > &ir_builder,
   const type cast_to,
   const expression &value
 ) {
   if(
     ( type_traits::is_reference( value.type() ) ||
     type_traits::is_pointer( value.type() ) ) &&
     ( type_traits::is_reference( cast_to ) ||
     type_traits::is_pointer( cast_to ) )
   ) return type_only_cast( context, ir_builder, cast_to, value );
   else if(
     type_traits::is_pointer( value.type() ) ||
     type_traits::is_promotable( cast_to )
   ) return address_cast( context, ir_builder, cast_to, value );
   else if(
     type_traits::is_promotable( value.type() ) ||
     type_traits::is_pointer( cast_to )
   ) return address_cast( context, ir_builder, cast_to, value );
   else if(
     type_traits::is_arithmetic( value.type() ) &&
     type_traits::is_arithmetic( cast_to )
   ) return arithmetic_cast( context, ir_builder, cast_to, value );
   else if(
     value.type().which() == cast_to.which()
   ) {
     if(
       type_traits::is_reference( value.type() ) ||
       type_traits::is_pointer( value.type() )
     ) return native_cast( context, ir_builder, cast_to, value );
     else return remove_const_cast( context, ir_builder, cast_to, value );
   }
   else if(
     type_traits::is_reference( value.type() )
   ) {
     if( type_traits::is_arithmetic( cast_to ) ||
         type_traits::is_aggregated( cast_to )
     ) {
       const auto dereferenced = remove_reference( context, ir_builder, value );
       return c_style_cast( context, ir_builder, cast_to, dereferenced );
     }
     else if( type_traits::is_lvalue_reference( cast_to ) ) {
       return reference_cast( context, ir_builder, cast_to, value );
     }
   }
   else if( type_traits::is_array( value.type() ) ) {
       return array_cast( context, ir_builder, cast_to, value );
   }
   throw exceptions::invalid_cast();
 }
Пример #15
0
int WorldSocket::open (void *a)
{
    ACE_UNUSED_ARG (a);

    // Prevent double call to this func.
    if (m_OutBuffer)
        return -1;

    // This will also prevent the socket from being Updated
    // while we are initializing it.
    m_OutActive = true;

    // Hook for the manager.
    if (sWorldSocketMgr->OnSocketOpen(this) == -1)
        return -1;

    // Allocate the buffer.
    ACE_NEW_RETURN (m_OutBuffer, ACE_Message_Block (m_OutBufferSize), -1);

    // Store peer address.
    ACE_INET_Addr remote_addr;

    if (peer().get_remote_addr(remote_addr) == -1)
    {
        sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::open: peer().get_remote_addr errno = %s", ACE_OS::strerror (errno));
        return -1;
    }

    m_Address = remote_addr.get_host_addr();

    // not an opcode. this packet sends raw string WORLD OF WARCRAFT CONNECTION - SERVER TO CLIENT"
    // because of our implementation, bytes "WO" become the opcode
    WorldPacket packet(MSG_VERIFY_CONNECTIVITY);
    packet << "RLD OF WARCRAFT CONNECTION - SERVER TO CLIENT";

    if (SendPacket(packet) == -1)
        return -1;

    // Register with ACE Reactor
    if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
    {
        sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno));
        return -1;
    }

    // reactor takes care of the socket from now on
    remove_reference();

    return 0;
}
Пример #16
0
int RASocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask)
{
    if(closing_)
        return -1;
    DEBUG_LOG("RASocket::handle_close");
    ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, outBufferLock, -1);

    closing_ = true;

    if (h == ACE_INVALID_HANDLE)
        peer ().close_writer ();
    remove_reference();
    return 0;
}
Пример #17
0
void BitVector::make_changable(void)
  {
    if (_block->_reference_count > 1)
      {
        BitVectorBlock *new_block =
                new BitVectorBlock(_block->_data_length,
                                     _block->_infinity_bit_is_one,
                                     _block->_num_significant_bits);
        for (size_t chunk_num = 0; chunk_num < _block->_data_length;
             ++chunk_num)
          {
            new_block->_data[chunk_num] = _block->_data[chunk_num];
          }
        remove_reference(_block);
        _block = new_block;
      }
    _has_count = false;
  }
Пример #18
0
//Copy Assignment Operator
msl::sprite& msl::sprite::operator=(const msl::sprite& copy)
{
	//Protect Against Self Assignment
	if(this!=&copy)
	{
		//Track References to Textures
		remove_reference();

		//Assign Members
		_texture=copy._texture;
		_number_of_frames=copy._number_of_frames;
		_width=copy._width;
		_height=copy._height;

		//Track References to Textures
		add_reference();
	}

	//Return
	return *this;
}
void destroy_domain_maintainer(domain_maintainer_t *dm) 
{
	int i, cnt;
	notifier_domain_t *d;
	
	if (!dm) return;
			
	DEBUG_LOG("destroying domain maintainer\n");

	cnt = ptr_vector_size(&dm->registered_domains);
	for (i = 0; i < cnt; i++) {
		d = ptr_vector_get(&dm->registered_domains, i);
		if (!d) continue;
		if (remove_reference(&d->ref)) {
			DEBUG_LOG("freeing domain: \'%.*s\'\n", FMT_STR(d->name));
			destroy_notifier_domain(d);
		}
	}
	ptr_vector_destroy(&dm->registered_domains);
	cds_mutex_destroy(&dm->mutex);
	cds_free(dm);
}
Пример #20
0
long WorldSocket::RemoveReference (void)
{
    return static_cast<long> (remove_reference());
}
Пример #21
0
BitVector::~BitVector(void)
  {
    remove_reference(_block);
  }
Пример #22
0
//Destructor
msl::sprite::~sprite()
{
	//Track References to Textures
	remove_reference();
}