void FiberReferenceMap::insert(void *src, void *copy) {
  ASSERT(lookup(src) == NULL);
  ASSERT(copy == NULL || reverseLookup(copy) == NULL);
  m_forward_references[src] = copy;
  if (copy) {
    m_reverse_references[copy] = src;
  }
}
示例#2
0
Angle CalibrationTable::fastReverseLookup(Angle encoderAngle)
{
#ifdef NZS_FAST_CAL
	//assume calibration is good
	if (fastCalVaild)
	{
		uint16_t x;
		x=((uint16_t)encoderAngle)/4;  //we only have 16384 values in table

		return (Angle)NVM->FastCal.angle[x];
	}else
	{
		return reverseLookup(encoderAngle);
	}
#else
	return reverseLookup(encoderAngle)
#endif
}
示例#3
0
int Address::lookupHostname(
	AWE::Core::String* pHostname
	)
{
	if ( m_pAddrInfo == 0 )
	{
		AWE_THROW( AddressException, "Address not resolved" );
	}

	AWE_CHECK_PTR( pHostname );

	*pHostname = "";

	return reverseLookup(
		NI_NUMERICSERV,			// resolve the port
		pHostname,
		0
		);
}
示例#4
0
int Address::getPort(
	AWE::uint16* pPort
	) const
{
	if ( m_pAddrInfo == 0 )
	{
		AWE_THROW( AddressException, "Address not resolved" );
	}

	AWE_CHECK_PTR( pPort );

	*pPort = 0;

	return reverseLookup(
		NI_NUMERICHOST |		// don't resolve the host
		NI_NUMERICSERV,			// resolve the port
		0,
		pPort
		);
}
示例#5
0
int Address::getAddress(
	AWE::Core::String* pAddress
	)
{
	if ( m_pAddrInfo == 0 )
	{
		AWE_THROW( AddressException, "Address not resolved" );
	}

	AWE_CHECK_PTR( pAddress );

	*pAddress = "";

	return reverseLookup(
		NI_NUMERICHOST |		// don't resolve the host
		NI_NUMERICSERV,			// resolve the port
		pAddress,
		0
		);
}
示例#6
0
void CalibrationTable::createFastCal(void)
{
#ifdef NZS_FAST_CAL
	int32_t i;
	uint16_t cs=0;
	uint16_t data[256];
	int32_t j;
	j=0;
	cs=0;
	LOG("setting fast calibration");
	for (i=0; i<16384; i++)
	{

		uint16_t x;
		x=reverseLookup(i*4);
		data[j]=x;
		j++;
		if (j>=256)
		{
			flashWrite(&NVM->FastCal.angle[i-255],data,256*sizeof(uint16_t));
			//LOG("Wrote fastcal at index %d-%d", i-255, i);
			j=0;
		}
		cs+=x;
	}
	//update the checksum
	flashWrite(&NVM->FastCal.checkSum,&cs,sizeof(uint16_t));
	fastCalVaild=true;

	//this is a quick test
	/*
			for (i=0; i<16384; i++)
			{
				LOG("fast Cal %d,%d,%d",i,NVM->FastCal.angle[i],(uint32_t)reverseLookup(i*4));
			}
	 */
#endif
}
示例#7
0
static char
decode(
    char letter,
    Encoder_Context *ctx)
{
    /* need to do reverse look up and where it is in
     * comparison to the current
     * can impact some stuff.
     */
    uint8_t indx = reverseLookup(letter, ctx);
    uint8_t ofs;
    char ret;

    /* it is not wrapped around */
    if (&(ctx->alphabet[indx]) > ctx->current)
    {
        ret = set[&(ctx->alphabet[indx]) - ctx->current];
    }
    else if (&(ctx->alphabet[indx]) < ctx->current)
    {
        ofs = ctx->end - ctx->current;
        ret = set[indx + ofs];
    }
    else
    {
        ret = set[0];
    }

    ctx->current += 1;

    if (ctx->current >= ctx->end)
    {
        ctx->current = ctx->alphabet;
    }

    return ret;
}