Пример #1
0
void can_prep_motor_speed( sCAN* mMsg, float_array mSpeed )
{
    mMsg->id 	  = create_CAN_eid( 0x00, ID_MOTOR_SPEED, MyInstance );
	if (config_byte_1 & MODE_USE_ENCODER)  {
		mMsg->data[0] = hi(EncoderSpeed);
		mMsg->data[1] = lo(EncoderSpeed);
	} else {
		for (int i=0; i<size; i++)
		    mMsg->data[i] = mSpeed.array[i];
	}
    mMsg->header.DLC = size;
    mMsg->header.rtr = 0;
}
Пример #2
0
void cpu_save_PC(void) {
	
	cpu.stack[cpu.sp] = lo(cpu.pc);
	
	cpu.sp --;
	
	cpu.stack[cpu.sp] = hi(cpu.pc);
	
	/* WTF? */
	
	cpu.sp --;
	
}
Пример #3
0
db_driver_command_type mysql_driver_command(packet * in_command)
{
    command_is_client_auth = 0;

    for (delegate_id i = 0; i < delegate_states_count; ++i) {
        /* we default to expecting a simple or tabular response with no row
           data */
        delegate_states[i].error = 0;
        delegate_states[i].expecting_rows = 0;
        delegate_states[i].expect_replies = REP_SIMPLE;
    }

    if (waiting_for_client_auth) {
        waiting_for_client_auth = 0;
        command_is_client_auth = 1;
        return DB_DRIVER_COMMAND_TYPE_OTHER;
    }

    enum enum_server_command command =
        (enum enum_server_command)(unsigned char)in_command->bytes[4];
    lo(LOG_DEBUG, "mysql_driver_command: I've got a %u packet...", command);

    db_driver_command_type type;

    /* if we see a QUIT command, don't expect the delegates to respond */
    switch (command) {
    case COM_QUIT:
        /* expecting delegates to quietly drop our connection */
        for (delegate_id i = 0; i < delegate_states_count; ++i) {
            delegate_states[i].expect_replies = REP_NONE;
        }
        done = 1;
        type = DB_DRIVER_COMMAND_TYPE_OTHER;
        break;
    case COM_QUERY:
        /* expecting row data to follow the initial response */
        for (delegate_id i = 0; i < delegate_states_count; ++i) {
            delegate_states[i].expecting_rows = 1;
        }
        type = DB_DRIVER_COMMAND_TYPE_SQL;
        break;
    case COM_FIELD_LIST:
        type = DB_DRIVER_COMMAND_TYPE_TABLE_META;
        break;
    default:
        type = DB_DRIVER_COMMAND_TYPE_UNSUPPORTED;
        break;
    }

    return type;
}
Пример #4
0
void can_prep_motor_values_raw( sCAN* mMsg )
{
    mMsg->id 	  = create_CAN_eid( 0x00, ID_MOTOR_VALUE, MyInstance );
	if (isConfigured(MODE_USE_ENCODER))  {
		mMsg->data[0] = hi(EncoderCount);
		mMsg->data[1] = lo(EncoderCount);	
	} else {
		mMsg->data[0] = hi(PotSample[1]);
		mMsg->data[1] = lo(PotSample[1]);
	}
	
	// Also send Currents Raw:
	mMsg->data[2] = hi(LeftCurrentSample[1] );
	mMsg->data[3] = lo(LeftCurrentSample[1] );
	mMsg->data[4] = hi(RightCurrentSample[1]);
	mMsg->data[5] = lo(RightCurrentSample[1]);

	word Duty = MotorDutyRequest * 100;
	mMsg->data[6] = hi(Duty);
	mMsg->data[7] = lo(Duty);	
    mMsg->header.DLC = 8;
    mMsg->header.rtr = 0;
}
Пример #5
0
void ProgramPage(u16 a) {
  DwSend(Bytes(0x66));
  DwSetRegs(29, Bytes(PGWRT, lo(a), hi(a))); // r29 = op (page write), Z = first byte address of page
  DwSetPC(BootSect());                       // Set PC that allows access to all of flash
  DwSend(Bytes(0x64));                       // Set up for single step mode
  DwOut(SPMCSR(), 29);                       // out SPMCSR,r29 (PGWRT)
  if (BootSect()) {
    DwInst(0x95E8);                          // spm
    while ((ReadSPMCSR() & 0x1F) != 0) {Wc('.'); Wflush();} // Wait while programming busy
  } else {
    DwSend(Bytes(0xD2, 0x95, 0xE8, 0x33));   // spm and break
    DwSync();
  }
}
Пример #6
0
void nes_cpu_adc_iy(void) {
	
	uint8_t address = cpu_get_op();
	
	log_iy("ADC", address);
	
	uint8_t _address = cpu.read(address);
	
	uint8_t value = cpu.read(_address + cpu.y);
	
	uint16_t result = cpu.a + value + cpu_get_C();
	
	if (~(cpu.a ^ value) & (cpu.a ^ lo(result)) & 0x80) cpu_set_V();
	
	if (hi(result)) cpu_set_C(); else cpu_clr_C();
	
	cpu.a = lo(result);
	
	cpu_check_Z(cpu.a); cpu_check_N(cpu.a);
	
	cpu.pc += 2;
	
}
Пример #7
0
/*----------------------------------------------------------------------------------------*/
boolean	make_vstr( uint8 *string, uint8 *prefix, int16 version, int16 radix )
{
	uint8	vstr_hi[6];
	uint8	vstr_lo[6];
	uint8	nullstr[4] = "";

	if( version )
	{
		itoa( hi(version), vstr_hi, radix );
		itoa( lo(version), vstr_lo, radix );
		
		if( lo(version) < radix )
			strcpy( nullstr, "0" );

		sprintf( string, "%s%s.%s%s", prefix, vstr_hi, nullstr, vstr_lo );
		return TRUE;
	}
	else
	{
		sprintf( string, "%s-", prefix );
		return FALSE;
	}
}
Пример #8
0
    void HexagonGame::checkAndSaveScore()
    {
        if(Config::getInvincible())
        {
            lo("hg::HexagonGame::checkAndSaveScore()")
                << "Not saving score - invincibility on\n";
            return;
        }

        if(assets.pIsLocal())
        {
            string localValidator{
                getLocalValidator(levelData->id, difficultyMult)};
            if(assets.getLocalScore(localValidator) < status.currentTime)
                assets.setLocalScore(localValidator, status.currentTime);
            assets.saveCurrentLocalProfile();
        }
        else
        {
            if(status.scoreInvalid || !Config::isEligibleForScore())
            {
                lo("hg::HexagonGame::checkAndSaveScore()")
                    << "Not sending/saving score - not eligible\n"
                    << Config::getUneligibilityReason() << "\n";
                return;
            }
            if(status.currentTime < 8)
            {
                lo("hg::HexagonGame::checkAndSaveScore()")
                    << "Not sending score - less than 8 seconds\n";
                return;
            }
            Online::trySendScore(
                levelData->id, difficultyMult, status.currentTime);
        }
    }
Пример #9
0
// コードページを取得します。
UINT Util::Text::GetCP(const CString& text)
{
	CString lo(text);
	lo.MakeLower();
	if		(lo == _T("utf-8"))		return CP_UTF8;
	else if	(lo == _T("shift_jis"))	return 932;
	else if	(lo == _T("ansi"))		return CP_ACP;
	else if	(lo == _T("utf8"))		return CP_UTF8;
	else if	(lo == _T("utf_8"))		return CP_UTF8;
	else if	(lo == _T("shiftjis"))	return 932;
	else if	(lo == _T("shift-jis"))	return 932;
	else if	(lo == _T("sjis"))		return 932;

	return CP_ACP;
}
Пример #10
0
int encode_const(char *data, int *bytes_left, argument *arg) {
	int bytes_written = 0;

	switch (Encoding) {
		case short_encoding:
			put_nybbles(0x0, Value);
			break;
		case medium_encoding:
			put_nybbles(0x1, hi(Value));
			put_byte(lo(Value));
			break;
		case byte_encoding:
			put_nybbles(0x2, 0x0);
			put_byte(Value);
			break;
		case long_encoding:
			put_nybbles(0x2, 0x1);
			put_byte(hi(Value));
			put_byte(lo(Value));
			break;
	}

	return bytes_written;
}
Пример #11
0
inline void
test_prox_topk_cone_biased_check_feasible(const ptrdiff_t k, const Type rho,
        const Type eps, std::vector<Type>& v) {
    sdca::prox_topk_cone_biased(v.begin(), v.end(), k, rho);

    Type sum = std::accumulate(v.begin(), v.end(), static_cast<Type>(0));

    Type lo(0), hi(sum / static_cast<Type>(k));
    std::for_each(v.begin(), v.end(), [=](const Type x) {
        ASSERT_GE(x, lo);
    });
    std::for_each(v.begin(), v.end(), [=](const Type x) {
        ASSERT_LE(x, hi + eps);
    });
}
Пример #12
0
/*
 * colour_in_use
 *
 * Check if a colour is set in any window.
 *
 */
int colour_in_use (zword colour)
{
    int max = (h_version == V6) ? 8 : 2;
    int i;

    for (i = 0; i < max; i++) {
        zword bg = hi (wp[i].colour);
        zword fg = lo (wp[i].colour);

        if (colour == fg || colour == bg)
            return 1;
    }

    return 0;

}/* colour_in_use */
Пример #13
0
void AbstractThread::threadBody()
{    
    {
        TLockMutex l( m_mutex );
        
        if ( isState( ThreadState_Running ) )
        {     
            TReverseMutexGuard r( m_mutex );
            run();        
        }
    }
    
    TLockUnique lo( m_mutex );
    setState( ThreadState_Stopped );
    m_condition.notify_all();
}
Пример #14
0
/*
 * z_sound_effect, load / play / stop / discard a sound effect.
 *
 *	zargs[0] = number of bleep (1 or 2) or sample
 *	zargs[1] = operation to perform (samples only)
 *	zargs[2] = repeats and volume (play sample only)
 *	zargs[3] = end-of-sound routine (play sample only, optional)
 *
 * Note: Volumes range from 1 to 8, volume 255 is the default volume.
 *	 Repeats are stored in the high byte, 255 is infinite loop.
 *
 */
void z_sound_effect (void)
{
    zword number = zargs[0];
    zword effect = zargs[1];
    zword volume = zargs[2];
    if (zargc < 1)
        number = 0;
    if (zargc < 2)
        effect = EFFECT_PLAY;
    if (zargc < 3)
        volume = 8;
    if (number >= 3 || number == 0)
    {
        locked = TRUE;
        if (story_id == LURKING_HORROR && (number == 9 || number == 16))
        {
            if (effect == EFFECT_PLAY)
            {
                next_sample = number;
                next_volume = volume;
                locked = FALSE;
                if (!playing)
                    start_next_sample ();
            }
            else locked = FALSE;
            return;
        }
        playing = FALSE;
        switch (effect)
        {
        case EFFECT_PREPARE:
            os_prepare_sample (number);
            break;
        case EFFECT_PLAY:
            start_sample (number, lo (volume), hi (volume), (zargc == 4) ? zargs[3] : 0);
            break;
        case EFFECT_STOP:
            os_stop_sample (number);
            break;
        case EFFECT_FINISH_WITH:
            os_finish_with_sample (number);
            break;
        }
        locked = FALSE;
    }
    else os_beep (number);
}/* z_sound_effect */
Пример #15
0
void SinaParserXml::fillMessage(Status &status, QString tagName, QString text)
{
    if(tagName=="id")
        status.setId(text);
    else if(tagName=="created_at")
    {
        QLocale lo(QLocale::C);
        QDateTime dateTime = lo.toDateTime(text, "ddd MMM dd HH:mm:ss +0800 yyyy");
        status.setCreatedAt(dateTime);
    }
    else if(tagName=="text")
        status.setText(text);
    else if (tagName == "sender_id")
        status.setSenderId(text);
    else if (tagName == "recipient_id")
        status.setRecipientId(text);
}
Пример #16
0
c_spectrum c_sampler_renderer::render_ray(scene_ptr scene, 
	const c_ray& ray, 
	const c_sample *sample, 
	c_rng& rng, 
	PARAM_OUT c_intersection *isect,
	PARAM_OUT c_spectrum *l) const
{
	c_spectrum lo(0.0f); 

	if (scene->query_intersection(ray, isect))
	{
		lo = m_surface_integrator->compute_li(scene, this, ray, *isect, sample, rng);
		//lo = c_spectrum(1.0f); 
	}
	 
	return lo; 
}
Пример #17
0
    bool TextureGetDifferenceSumDataTest(bool create, int width, int height, const Func3 & f)
    {
        bool result = true;

        Data data(f.description);

        TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "].");

        View src(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View lo(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View hi(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        int64_t s1, s2;

        if(create)
        {
            FillRandom(src);
            FillRandom(lo);
            FillRandom(hi);

            TEST_SAVE(src);
            TEST_SAVE(lo);
            TEST_SAVE(hi);

            f.Call(src, lo, hi, &s1);

            TEST_SAVE(s1);
        }
        else
        {
            TEST_LOAD(src);
            TEST_LOAD(lo);
            TEST_LOAD(hi);

            TEST_LOAD(s1);

            f.Call(src, lo, hi, &s2);

            TEST_SAVE(s2);

            TEST_CHECK_VALUE(s);
        }

        return result;
    }
Пример #18
0
int NCMessageBox( NCDialogParent* parent, const char* utf8head, const char* utf8txt, bool red, ButtonDataNode* buttonList )
{
	std::vector<unicode_t> str = utf8_to_unicode( utf8txt );
	ccollect<unicode_t> buf;

	unicode_t* s = str.data();
	int lLine = 0;

	for ( ; *s; s++ )
	{
		if ( lLine > 100 )
		{
			buf.append( '\n' );
			lLine = 0;
		}

		if ( *s == '\n' )
		{
			lLine = 0;
		}

		buf.append( *s );
		lLine++;
	}

	buf.append( 0 );


	NCDialog d( ::createDialogAsChild, red ? uiNCRedMessageBox : uiNCMessageBox, parent, utf8_to_unicode( utf8head ).data(), buttonList ); //, red ? 0xFF:0xD8E9EC, red ? 0xFFFFFF :0x1);
	StaticLine text( 0, &d, buf.ptr() );

	text.Show();
	text.Enable();
	Layout lo( 3, 3 );
	lo.LineSet( 0, 5 );
	lo.LineSet( 2, 5 );
	lo.ColSet( 0, 15 );
	lo.ColSet( 2, 15 );
	lo.AddWin( &text, 1, 1 );
	d.AddLayout( &lo );

	d.SetPosition();
	return d.DoModal();
}
Пример #19
0
int KillCmdDialog( NCDialogParent* parent, const unicode_t* cmd )
{
	NCDialog d( ::createDialogAsChild, uiKillCmdDialog, parent, utf8_to_unicode( "Kill command" ).data(), bListKill ); //,  0xD8E9EC, 0);
	StaticLine text( 0, &d, cmd );

	text.Show();
	text.Enable();
	Layout lo( 3, 3 );
	lo.LineSet( 0, 5 );
	lo.LineSet( 2, 5 );
	lo.ColSet( 0, 15 );
	lo.ColSet( 2, 15 );
	lo.AddWin( &text, 1, 1 );
	d.AddLayout( &lo );

	d.SetPosition();
	return d.DoModal();

}
Пример #20
0
		void loadConfig(const vector<string>& mOverridesIds)
		{
			lo("::loadConfig") << "loading config" << endl;

			for(const auto& p : getScan<ssvufs::Mode::Single, ssvufs::Type::File, ssvufs::Pick::ByExt>("ConfigOverrides/", ".json"))
			{
				if(contains(mOverridesIds, p.getFileNameNoExtensions()))
				{
					const auto& overrideRoot(readFromFile(p));
					for(auto itr(begin(overrideRoot)); itr != end(overrideRoot); ++itr) root[getKey(itr)] = *itr;
				}
			}

			lvm.syncFromObj();

			if(getWindowedAutoResolution()) applyAutoWindowedResolution();
			if(getFullscreenAutoResolution()) applyAutoFullscreenResolution();

			recalculateSizes();

		}
Пример #21
0
void TexturedFeather::shapeVanes()
{
	const short numSeg = numSegment();
	if(type() == 0) {
		for(short i = 0; i <= numSeg; i++) {	
			*m_vane[0].railCV(i, 0) = Vector3F(*segmentQuillTexcoord(i));
			*m_vane[1].railCV(i, 0) = Vector3F(*segmentQuillTexcoord(i));
			for(short j = 0; j < 3; j++) {
				*m_vane[0].railCV(i, j + 1) = Vector3F(*segmentVaneTexcoord(i, 0, j));
				*m_vane[1].railCV(i, j + 1) = Vector3F(*segmentVaneTexcoord(i, 1, j));
			}
		}
	}
	else {
		Vector3F lo(*segmentQuillTexcoord(0));
		Vector3F hi(*segmentQuillTexcoord(1));
		
		hi -= (hi - lo) * .35f;
		Vector3F dv = lo - hi;

		*m_vane[0].railCV(0, 0) = hi;
		*m_vane[0].railCV(1, 0) = hi + dv * .33f;
		*m_vane[0].railCV(2, 0) = hi + dv * .67f;
		*m_vane[0].railCV(3, 0) = lo;
		
		*m_vane[1].railCV(0, 0) = hi;
		*m_vane[1].railCV(1, 0) = hi + dv * .33f;
		*m_vane[1].railCV(2, 0) = hi + dv * .67f;
		*m_vane[1].railCV(3, 0) = lo;
		
		for(short i = 1; i <= numSeg; i++) {	
			*m_vane[0].railCV(0, i) = Vector3F(*segmentQuillTexcoord(i));
			*m_vane[1].railCV(0, i) = Vector3F(*segmentQuillTexcoord(i));
			for(short j = 0; j < 3; j++) {
				*m_vane[0].railCV(j + 1, i) = Vector3F(*segmentVaneTexcoord(i, 0, j));
				*m_vane[1].railCV(j + 1, i) = Vector3F(*segmentVaneTexcoord(i, 1, j));
			}
		}
	}
}
Пример #22
0
void PickingRenderer::cube(const vgl::Vec3f& color)
{
  vgl::Vec3f lo(-0.5, -0.5, -0.5);
  vgl::Vec3f hi( 0.5,  0.5,  0.5);

  glColor3fv(color.data);
  glBegin(GL_QUADS);

  glVertex3f(lo.x, lo.y, lo.z);
  glVertex3f(hi.x, lo.y, lo.z);
  glVertex3f(hi.x, hi.y, lo.z);
  glVertex3f(lo.x, hi.y, lo.z);

  glVertex3f(lo.x, lo.y, hi.z);
  glVertex3f(hi.x, lo.y, hi.z);
  glVertex3f(hi.x, hi.y, hi.z);
  glVertex3f(lo.x, hi.y, hi.z);

  glVertex3f(lo.x, lo.y, lo.z);
  glVertex3f(lo.x, lo.y, hi.z);
  glVertex3f(lo.x, hi.y, hi.z);
  glVertex3f(lo.x, hi.y, lo.z);

  glVertex3f(hi.x, lo.y, lo.z);
  glVertex3f(hi.x, lo.y, hi.z);
  glVertex3f(hi.x, hi.y, hi.z);
  glVertex3f(hi.x, hi.y, lo.z);

  glVertex3f(lo.x, lo.y, lo.z);
  glVertex3f(hi.x, lo.y, lo.z);
  glVertex3f(hi.x, lo.y, hi.z);
  glVertex3f(lo.x, lo.y, hi.z);

  glVertex3f(lo.x, hi.y, lo.z);
  glVertex3f(hi.x, hi.y, lo.z);
  glVertex3f(hi.x, hi.y, hi.z);
  glVertex3f(lo.x, hi.y, hi.z);

  glEnd();
}
Пример #23
0
/**
 * For ACL address matching make sure that the two addresses, *this
 * which is the low address and hiPeer which is the high address, are
 * both numeric ip addresses of the same family and that hi > *this.
 *
 * Note that if the addresses resolve to more than one struct addrinfo
 * then this and the hiPeer must be equal. This avoids having to do
 * difficult range checks where the this and hiPeer both resolve to
 * multiple IPv4 or IPv6 addresses.
 *
 * This check is run at acl file load time and not at run tme.
 */
bool SocketAddress::isComparable(const SocketAddress& hiPeer) const {
    try {
        // May only compare if this socket is IPv4 or IPv6
        SocketAddress lo(*this);
        const ::addrinfo& peerLoInfo = getAddrInfo(lo);
        if (!(peerLoInfo.ai_family == AF_INET || peerLoInfo.ai_family == AF_INET6)) {
            return false;
        }
        try {
            // May only compare if peer socket is same family
            SocketAddress hi(hiPeer);
            const ::addrinfo& peerHiInfo = getAddrInfo(hi);
            if (peerLoInfo.ai_family != peerHiInfo.ai_family) {
                return false;
            }
            // Host names that resolve to lists are allowed if they are equal.
            // For example: localhost, or fjord.lab.example.com
            if ((*this).asString() == hiPeer.asString()) {
                return true;
            }
            // May only compare if this and peer resolve to single address.
            if (lo.nextAddress() || hi.nextAddress()) {
                return false;
            }
            // Make sure that the lo/hi relationship is ok
            int res;
            if (!compareAddresses(peerLoInfo, peerHiInfo, res) || res < 0) {
                return false;
            }
            return true;
        } catch (Exception) {
            // failed to resolve hi
            return false;
        }
    } catch (Exception) {
        // failed to resolve lo
        return false;
    }
}
Пример #24
0
 vector<int> mysort(vector<int>& x){ //non-descending order
     vector<int> arr = x;
     if(arr.size() == 1){
         return arr;
     }
     if(arr.size() == 2){
         if(arr[0]>arr[1]){
             int tmp = arr[0];
             arr[0] = arr[1];
             arr[1] = tmp;
         }
         return arr;
     }
     int midpoint = arr.size() / 2;
     vector<int> lo (arr.begin(),arr.begin() + midpoint);
     vector<int> hi (arr.begin() + midpoint, arr.end());
     lo = mysort(lo);
     hi = mysort(hi);
     vector<int> retval;
     retval.reserve(lo.size()+hi.size());
     int ptr1 = 0, ptr2 = 0;
     while(lo.size() > ptr1  && hi.size() > ptr2){
         if(lo[ptr1]<hi[ptr2]){
             retval.push_back((int)lo[ptr1]);
             ptr1++;
             if(ptr1 >= lo.size()){
                 retval.insert(retval.end(), hi.begin() + ptr2, hi.end());
             }//end if
         }else{
             retval.push_back((int)hi[ptr2]);
             ptr2++;
             if(ptr2 >= hi.size()){
                 retval.insert(retval.end(), lo.begin() + ptr1, lo.end());
             }//end if
         }//end if lo and hi
     }//end while
     return retval;
 }//end mysort
Пример #25
0
void rgb_stretch(QImage &img, const QRect &rect)
{
  int rmin, rmax;
  int gmin, gmax;
  int bmin, bmax;
  makeHistogram(img, rect, getRed,   256, &rmin, &rmax);
  makeHistogram(img, rect, getGreen, 256, &gmin, &gmax);
  makeHistogram(img, rect, getBlue,  256, &bmin, &bmax);

  RGBV lo(rmin/255.0, gmin/255.0, bmin/255.0);
  RGBV stretch(rmax==rmin? 1.0 : 255.0/(rmax-rmin),
               gmax==gmin? 1.0 : 255.0/(gmax-gmin),
               bmax==bmin? 1.0 : 255.0/(bmax-bmin));
  for (int y=rect.top(); y<=rect.bottom(); y++)
    for (int x=rect.left(); x<=rect.right(); x++)
    {
      RGBV c(img.pixel(x, y));
      c.addk(lo, -1);
      c.mulv(stretch);
      c.clamp();
      img.setPixel(x, y, c.toQRgb());
    }
}
Пример #26
0
    bool TextureGetDifferenceSumAutoTest(int width, int height, const Func3 & f1, const Func3 & f2)
    {
        bool result = true;

        TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " [" << width << ", " << height << "].");

        View src(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        FillRandom(src);
        View lo(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        FillRandom(lo);
        View hi(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        FillRandom(hi);

        int64_t s1, s2;

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(src, lo, hi, &s1));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(src, lo, hi, &s2));

        TEST_CHECK_VALUE(s);

        return result;
    }
Пример #27
0
void z_get_wind_prop (void)
{

    flush_buffer ();

    if (zargs[1] < 16)
        store (((zword *) (wp + winarg0 ())) [zargs[1]]);

    else if (zargs[1] == 16)
        store (os_to_true_colour (lo (wp [winarg0 ()].colour)));

    else if (zargs[1] == 17) {

        zword bg = hi (wp [winarg0 ()].colour);

        if (bg == TRANSPARENT_COLOUR)
            store ((zword) -4);
        else
            store (os_to_true_colour (bg));

    } else
        runtime_error (ERR_ILL_WIN_PROP);

}/* z_get_wind_prop */
Пример #28
0
TEST(dynamic_loader, unknown_so_file) {
  EXPECT_THROW(dynamic_loader lo("unknown_file.so"), converter_exception);
}
Пример #29
0
int msg_send( msg_t *msg )
{
	unsigned char header[MSG_PREAMBLE_LEN + 3];
	unsigned char checksum[2];
	unsigned short crc;
	int i, res;

	// Preamble
	for ( i = 0; i < MSG_PREAMBLE_LEN; i++ ) header[i] = MSG_PREAMBLE_BYTE;

	// Command ID
	header[MSG_PREAMBLE_LEN] = msg->id;

	// Length
	header[MSG_PREAMBLE_LEN + 1] = lo( msg->len );
	header[MSG_PREAMBLE_LEN + 2] = hi( msg->len );

	// Checksum
	crc = checksum_crc16( header, 6 );
	crc = checksum_update_crc16( msg->data, msg->len, crc );

	checksum[0] = lo( crc );
	checksum[1] = hi( crc );

	if ( interface->write )
	{

		unsigned char *buf = malloc( 6 + msg->len + 2 ); // 6+2 fixes (PREAMBLE, ID, PAILOAD / ... / CRC)
		memcpy( buf, header, 6 );
		memcpy( buf + 6, msg->data, msg->len );
		memcpy( buf + 6 + msg->len, (unsigned char *) &crc, 2 );

		res = interface->write( buf, 6 + msg->len + 2 );
		if ( res < 6 + msg->len + 2 )
		{
			interface->close();
			quit( "Failed to submit message checksum" );
		}

		free( buf );

// The following implementation doesn't work:
//
//		// Submit header
//		res = interface->write( header, 6 );
//		if ( res < 6 )
//		{
//			interface->close();
//			quit( "Failed to submit message header" );
//		}
//
//		// Submit payload
//		res = interface->write( msg->data, msg->len );
//		if ( res < msg->len )
//		{
//			interface->close();
//			quit( "Failed to submit message payload" );
//		}
//
//		res = interface->write( (unsigned char *) &crc, 2 );
//		if ( res < sizeof( crc ) )
//		{
//			interface->close();
//			quit( "Failed to submit message checksum" );
//		}

//		unsigned short check = checksum_crc16( header, 6 );
//		check = checksum_update_crc16( msg->data, msg->len, check );
//		check = checksum_update_crc16( (unsigned char *) &crc, sizeof( short ), check );

		return msg->len + 8;
	}

	return -1;
}
Пример #30
0
inline UInt64::operator uint64_t() { return ((uint64_t)hi()) << 32 | lo(); }