• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ BSWAP32函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BSWAP32函数的典型用法代码示例。如果您正苦于以下问题:C++ BSWAP32函数的具体用法?C++ BSWAP32怎么用?C++ BSWAP32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BSWAP32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CopyLineQwordsSwap

static void CopyLineQwordsSwap(void * dst, const void * src, u32 qwords)
{
#ifdef FAST_TMEM_COPY
	u32* src32 = (u32*)src;
	u32* dst32 = (u32*)dst;

	DAEDALUS_ASSERT( ((uintptr_t)src32&0x3 )==0, "src is not aligned!");

	while(qwords--)
	{
		dst32[1]  = BSWAP32(src32[0]);
		dst32[0]  = BSWAP32(src32[1]);
		dst32 += 2;
		src32 += 2;
	}
#else
	u8* src8 = (u8*)src;
	u8* dst8 = (u8*)dst;
	u32 bytes = qwords * 8;
	while(bytes--)
	{
		*(u8*)((uintptr_t)dst8++ ^ 0x4)  = *(u8*)((uintptr_t)src8++ ^ U8_TWIDDLE);
	}
#endif
}
开发者ID:hulkholden,项目名称:daedalus,代码行数:25,代码来源:RDPStateManager.cpp


示例2: IsGoodGRFConfigList

/** Check if all GRFs in the GRF config from a savegame can be loaded.
 * @param grfconfig GrfConfig to check
 * @return will return any of the following 3 values:<br>
 * <ul>
 * <li> GLC_ALL_GOOD: No problems occured, all GRF files were found and loaded
 * <li> GLC_COMPATIBLE: For one or more GRF's no exact match was found, but a
 *     compatible GRF with the same grfid was found and used instead
 * <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all
 * </ul> */
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
{
	GRFListCompatibility res = GLC_ALL_GOOD;

	for (GRFConfig *c = grfconfig; c != NULL; c = c->next) {
		const GRFConfig *f = FindGRFConfig(c->ident.grfid, c->ident.md5sum);
		if (f == NULL) {
			char buf[256];

			/* If we have not found the exactly matching GRF try to find one with the
			 * same grfid, as it most likely is compatible */
			f = FindGRFConfig(c->ident.grfid);
			if (f != NULL) {
				md5sumToString(buf, lastof(buf), c->ident.md5sum);
				DEBUG(grf, 1, "NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, buf);
				if (!HasBit(c->flags, GCF_COMPATIBLE)) {
					/* Preserve original_md5sum after it has been assigned */
					SetBit(c->flags, GCF_COMPATIBLE);
					memcpy(c->original_md5sum, c->ident.md5sum, sizeof(c->original_md5sum));
				}

				/* Non-found has precedence over compatibility load */
				if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE;
				goto compatible_grf;
			}

			/* No compatible grf was found, mark it as disabled */
			md5sumToString(buf, lastof(buf), c->ident.md5sum);
			DEBUG(grf, 0, "NewGRF %08X (%s) not found; checksum %s", BSWAP32(c->ident.grfid), c->filename, buf);

			c->status = GCS_NOT_FOUND;
			res = GLC_NOT_FOUND;
		} else {
compatible_grf:
			DEBUG(grf, 1, "Loading GRF %08X from %s", BSWAP32(f->ident.grfid), f->filename);
			/* The filename could be the filename as in the savegame. As we need
			 * to load the GRF here, we need the correct filename, so overwrite that
			 * in any case and set the name and info when it is not set already.
			 * When the GCF_COPY flag is set, it is certain that the filename is
			 * already a local one, so there is no need to replace it. */
			if (!HasBit(c->flags, GCF_COPY)) {
				free(c->filename);
				c->filename = strdup(f->filename);
				memcpy(c->ident.md5sum, f->ident.md5sum, sizeof(c->ident.md5sum));
				if (c->name == NULL && f->name != NULL) c->name = strdup(f->name);
				if (c->info == NULL && f->info != NULL) c->info = strdup(f->info);
				c->error = NULL;
			}
		}
	}

	return res;
}
开发者ID:jemmyw,项目名称:openttd,代码行数:62,代码来源:newgrf_config.cpp


示例3: CopyLine

static inline void CopyLine(void * dst, const void * src, u32 bytes)
{
#ifdef FAST_TMEM_COPY
	u32* src32 = (u32*)src;
	u32* dst32 = (u32*)dst;

	DAEDALUS_ASSERT((bytes&0x3)==0, "CopyLine: Remaning bytes! (%d)",bytes);

	u32 size32 = bytes >> 2;
	u32 src_alignment = (uintptr_t)src32&0x3;

	if(src_alignment == 0)
	{
		while (size32--)
		{
			*dst32++ = BSWAP32(src32[0]);
			src32++;
		}
	}
	else
	{
		// Zelda and DK64 have unaligned copies. so let's optimize 'em
		src32 = (u32*)((uintptr_t)src & ~0x3);
		u32 src_tmp = *src32++;
		u32 dst_tmp = 0;

		// calculate offset 3..1..2
		u32 offset = 4-src_alignment;
		u32 lshift = src_alignment<<3;
		u32 rshift = offset<<3;

		while(size32--)
		{
			dst_tmp = src_tmp << lshift;
			src_tmp = *src32++;
			dst_tmp|= src_tmp >> rshift;
			*dst32++ = BSWAP32(dst_tmp);
		}
		src32 -= offset;
	}
#else
	u8* src8 = (u8*)src;
	u8* dst8 = (u8*)dst;
	while(bytes--)
	{
		*dst8++ = *(u8*)((uintptr_t)src8++ ^ U8_TWIDDLE);
	}
#endif
}
开发者ID:hulkholden,项目名称:daedalus,代码行数:49,代码来源:RDPStateManager.cpp


示例4: memnew

void EditorExportPlatformOSX::_make_icon(const Image& p_icon,Vector<uint8_t>& icon) {


	Ref<ImageTexture> it = memnew( ImageTexture );
	int size=512;

	Vector<uint8_t> data;

	data.resize(8);
	data[0]='i';
	data[1]='c';
	data[2]='n';
	data[3]='s';

	const char *name[]={"ic09","ic08","ic07","icp6","icp5","icp4"};
	int index=0;

	while(size>=16) {

		Image copy = p_icon;
		copy.convert(Image::FORMAT_RGBA);
		copy.resize(size,size);
		it->create_from_image(copy);
		String path = EditorSettings::get_singleton()->get_settings_path()+"/tmp/icon.png";
		ResourceSaver::save(path,it);

		FileAccess *f = FileAccess::open(path,FileAccess::READ);
		ERR_FAIL_COND(!f);

		int ofs = data.size();
		uint32_t len = f->get_len();
		data.resize(data.size()+len+8);
		f->get_buffer(&data[ofs+8],len);
		memdelete(f);
		len+=8;
		len=BSWAP32(len);
		copymem(&data[ofs],name[index],4);
		encode_uint32(len,&data[ofs+4]);
		index++;
		size/=2;
	}

	uint32_t total_len = data.size();
	total_len = BSWAP32(total_len);
	encode_uint32(total_len,&data[4]);

	icon=data;
}
开发者ID:9cat,项目名称:godot,代码行数:48,代码来源:export.cpp


示例5: global_user_list_cb

static void
global_user_list_cb (USER * user, struct guldata *data)
{
    ASSERT (validate_user (user));
    ASSERT (data != 0);
    if (data->flags)
    {
	/* selectively display users based on user level/muzzle/cloak */
	if (!
	    (((data->flags & ON_GFLAG_ADMIN) && user->level == LEVEL_ADMIN)
	     || ((data->flags & ON_GFLAG_ELITE) && user->level == LEVEL_ELITE)
	     || ((data->flags & ON_GFLAG_MODERATOR)
		 && user->level == LEVEL_MODERATOR)
	     || ((data->flags & ON_GFLAG_USERS) && user->level == LEVEL_USER)
	     || ((data->flags & ON_GFLAG_LEECH) && user->level == LEVEL_LEECH)
	     || ((data->flags & ON_GFLAG_MUZZLED) && user->muzzled)
	     || ((data->flags & ON_GFLAG_CLOAKED) && user->cloaked)
	     || ((data->flags & ON_GFLAG_USERIP) && (user->ip & data->mask) == (data->ip & data->mask))))
	    return;
    }
    if (data->server && *data->server != '*' &&
	strcasecmp (data->server, user->server) != 0)
	return;			/* no match */
    send_cmd (data->con, MSG_SERVER_GLOBAL_USER_LIST, "%s %s", user->nick,
	      my_ntoa (BSWAP32 (user->ip)));
}
开发者ID:OS2World,项目名称:APP-SERVER-opennap,代码行数:26,代码来源:list_users.c


示例6: BSWAP32

int DumpScan::process(DumpDataList::iterator startDump, unsigned long startByte)
{
	unsigned long min = m_address - m_maxOffset;
	unsigned long max = m_address;
	if (m_maxOffset > m_address)
		min = 0;
	m_counter = 0;
	for (DumpDataList::iterator it = startDump; it!= m_dumps.end(); ++it)
	{
		char *data = (*it)->data;
		CHECK_CANCEL;
		for (unsigned long i=startByte; i<((*it)->header.end - (*it)->header.begin)-3; ++i)
		{
			unsigned long currentAddress = BSWAP32(*(unsigned long*)(&data[i]));
			CHECK_CANCEL;
			if ( currentAddress >= min && currentAddress <= max) //we want this
			{
				PointerOffsets po = m_offsets;
				po.push_front(m_address - currentAddress);
				m_results.push_back(ScanResult(i+(*it)->header.begin, po));
				if (++m_counter >= m_maxResults)
				{
					m_counter = 0;
					m_currentDump = it;
					m_currentByte = i+1;
					return DUMP_SCAN_STATUS_CONTINUE;
				}
			}
		}
	}
	return DUMP_SCAN_STATUS_DONE;
}
开发者ID:Encapsulate,项目名称:CCCheat,代码行数:32,代码来源:DumpScan.cpp


示例7: cmd_page_erase

void cmd_page_erase()
{
	int adrs=BSWAP32(PacketFromPC.adrs);
	if( check_flash_adrs(adrs)) {
		FLASH_ErasePage(adrs);
	}
}
开发者ID:iruka-,项目名称:ARM_BOOTLOADER,代码行数:7,代码来源:monit.c


示例8: cmd_page_write

/********************************************************************
 *	FLASHのページ単位書き込み.	(引数は書き込みadrsとsize)
 ********************************************************************
  STM32では、word単位で書き込みが可能. (flush動作不要)

  他のマイコン(LPCなど)では、
  	実際にはRAM上のページバッファにword単位でためておいて、
  	最後にsize=0を指定してページバッファを一発書き込みする実装になることもある.
 

 */
void cmd_page_write()
{
	int  *p = PacketFromPC.data;
	int   i;
	int   size = BSWAP16(PacketFromPC.size);
	int	   adr = BSWAP32(PacketFromPC.adrs);

	// ここでbyte数をword数に変換している.
	size = (size+3) >> 2;		// size は4byte単位に限る.

//#if	defined(LPC1343)||defined(LPC2388)
	if(size==0) {				// size が 0 のときは書き込みflush動作をする.
		FLASH_ProgramPage(adr);	// これはSTM32に限り不要(ダミー関数)
		return ;
	}
//#endif

	for(i=0; i<size; i++) {
		if( check_flash_adrs(adr) ) {
			FLASH_ProgramWord(adr, *p);	// STM32では直接FLUSHに書く.
		}								// 他のマイコンでは、ページバッファに記録.
		p++;
		adr+=4;
	}
}
开发者ID:iruka-,项目名称:ARM_BOOTLOADER,代码行数:36,代码来源:monit.c


示例9: cmd_echo

/********************************************************************
 *	接続テストの返答
 ********************************************************************
 */
void cmd_echo(void)
{
	int *fl_stat = (int*) &PacketToPC.rawint[2];
	PacketToPC.raw[1]=DEVID;				// PIC25/14K
	PacketToPC.raw[2]=VER_L;				// version.L
	PacketToPC.raw[3]=VER_H;				// version.H
	PacketToPC.raw[4]=DEV_LOADER;			// bootloader
	PacketToPC.raw[5]=PacketFromPC.raw[1];	// ECHOBACK

	fl_stat[0] = BSWAP32(FLASH_END_ADR);
	fl_stat[1] = BSWAP32(search_flash_end(FLASH_END_ADR));
	fl_stat[2] = BSWAP32(total_errs);

	total_errs=0;
	ToPcRdy = 1;
}
开发者ID:iruka-,项目名称:ARM_BOOTLOADER,代码行数:20,代码来源:monit.c


示例10: cmd_page_write

void cmd_page_write()
{
	int   i;
	int   size = BSWAP16(PacketFromPC.size);
	int	   adr = BSWAP32(PacketFromPC.adrs);
	int     *p = 		 PacketFromPC.data;
	size = (size+3) >> 2;

#if	defined(LPC1343)||defined(LPC2388)
	if(size==0) {
		FLASH_ProgramPage(adr);
		return ;
	}
#endif
	if(	size <= (48) ) {
		total_errs += flash_write(adr,size,p);
		return;
	}

	while(size>0) {
		int buf[64/4];

		int len = size;
		if( len >= BLK_SIZE ) {len = BLK_SIZE;}

		USBgetpacket((uchar*)buf,len);

		total_errs += flash_write(adr, len ,buf);
		size -= len;
		adr  += len;
	}
}
开发者ID:iruka-,项目名称:ARM_BOOTLOADER,代码行数:32,代码来源:monit.c


示例11: memnew

void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data) {

	Ref<ImageTexture> it = memnew(ImageTexture);
	int size = 512;

	Vector<uint8_t> data;

	data.resize(8);
	data[0] = 'i';
	data[1] = 'c';
	data[2] = 'n';
	data[3] = 's';

	const char *name[] = { "ic09", "ic08", "ic07", "icp6", "icp5", "icp4" };
	int index = 0;

	while (size >= 16) {

		Ref<Image> copy = p_icon; // does this make sense? doesn't this just increase the reference count instead of making a copy? Do we even need a copy?
		copy->convert(Image::FORMAT_RGBA8);
		copy->resize(size, size);
		it->create_from_image(copy);
		String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("icon.png");
		ResourceSaver::save(path, it);

		FileAccess *f = FileAccess::open(path, FileAccess::READ);
		ERR_FAIL_COND(!f);

		int ofs = data.size();
		uint32_t len = f->get_len();
		data.resize(data.size() + len + 8);
		f->get_buffer(&data[ofs + 8], len);
		memdelete(f);
		len += 8;
		len = BSWAP32(len);
		copymem(&data[ofs], name[index], 4);
		encode_uint32(len, &data[ofs + 4]);
		index++;
		size /= 2;
	}

	uint32_t total_len = data.size();
	total_len = BSWAP32(total_len);
	encode_uint32(total_len, &data[4]);

	p_data = data;
}
开发者ID:nakoff,项目名称:godot,代码行数:47,代码来源:export.cpp


示例12: byteswap_msg

static void
byteswap_msg (ossmix_commad_packet_t * msg)
{
  BSWAP32 (msg->cmd);
  BSWAP32 (msg->p1);
  BSWAP32 (msg->p2);
  BSWAP32 (msg->p3);
  BSWAP32 (msg->p4);
  BSWAP32 (msg->p5);
  BSWAP32 (msg->ack_rq);
  BSWAP32 (msg->unsolicited);
  BSWAP32 (msg->payload_size);
}
开发者ID:Open-Sound-System,项目名称:Open-Sound-System,代码行数:13,代码来源:libossmix_tcp.c


示例13: try_connect

static void
try_connect (server_auth_t * auth)
{
    int     f;
    CONNECTION *cli;
    unsigned int ip;

    /* attempt a connection.  we do this nonblocking so that the server
       doesn't halt if it takes a long time to connect */
    f = make_tcp_connection (auth->name, auth->port, &ip);
    if (f == -1)
	return;

    cli = new_connection ();
    if (!cli)
	goto error;
    cli->fd = f;
    cli->host = STRDUP (auth->alias ? auth->alias : auth->name);
    if (!cli->host)
    {
	OUTOFMEMORY ("try_connect");
	goto error;
    }
    cli->server_login = 1;
    if ((cli->opt.auth = CALLOC (1, sizeof (AUTH))) == 0)
    {
	OUTOFMEMORY ("try_connect");
	goto error;
    }
    cli->opt.auth->nonce = generate_nonce ();
    if (!cli->opt.auth->nonce)
    {
	log_message ("try_connect: could not generate nonce, closing connection");
	goto error;
    }
    cli->ip = BSWAP32 (ip);
    cli->port = auth->port;

    if (add_client (cli, 1/* server connection */))
	goto error;

    return;
  error:
    log_message ("try_connect: closing connection");
    if (cli)
    {
	CLOSE (cli->fd);
	if (cli->host)
	    FREE (cli->host);
	if (cli->opt.auth)
	{
	    if (cli->opt.auth->nonce)
		FREE (cli->opt.auth->nonce);
	    FREE (cli->opt.auth);
	}
	FREE (cli);
    }
}
开发者ID:dterweij,项目名称:opennap,代码行数:58,代码来源:server_connect.c


示例14: BSWAP32

void StreamPeer::put_32(int32_t p_val) {

	if (big_endian) {
		p_val = BSWAP32(p_val);
	}
	uint8_t buf[4];
	encode_uint32(p_val, buf);
	put_data(buf, 4);
}
开发者ID:allkhor,项目名称:godot,代码行数:9,代码来源:stream_peer.cpp


示例15: get_data

int32_t StreamPeer::get_32() {

	uint8_t buf[4];
	get_data(buf, 4);
	uint32_t r = decode_uint32(buf);
	if (big_endian) {
		r = BSWAP32(r);
	}
	return r;
}
开发者ID:allkhor,项目名称:godot,代码行数:10,代码来源:stream_peer.cpp


示例16: CopyLineSwap

static inline void CopyLineSwap(void * dst, const void * src, u32 bytes)
{
	u32* src32 = (u32*)src;
	u32* dst32 = (u32*)dst;

#ifdef FAST_TMEM_COPY
	DAEDALUS_ASSERT((bytes&0x7)==0, "CopyLineSwap: Remaning bytes! (%d)",bytes);

	if( ((uintptr_t)src32&0x3 )==0)
	{
		u32 size64 = bytes >> 3;

		while (size64--)
		{
			dst32[0] = BSWAP32(src32[1]);
			dst32[1] = BSWAP32(src32[0]);
			dst32 += 2;
			src32 += 2;
		}
	}
开发者ID:hulkholden,项目名称:daedalus,代码行数:20,代码来源:RDPStateManager.cpp


示例17: cmd_set_mode

/********************************************************************
 *	データ引取りモードの設定
 ********************************************************************
 */
void cmd_set_mode(void)
{
	poll_mode = BSWAP16( PacketFromPC.size );
	poll_addr = (uchar  *) BSWAP32( PacketFromPC.adrs );

	if(	poll_mode == POLL_ANALOG) {
//		mInitPOT();
//		ADCON0bits.GO = 1;              // Start AD conversion
	}

	make_report();
}
开发者ID:iruka-,项目名称:ARM_BOOTLOADER,代码行数:16,代码来源:monit.c


示例18: encode_float

void StreamPeer::put_float(float p_val) {

	uint8_t buf[4];

	encode_float(p_val, buf);
	if (big_endian) {
		uint32_t *p32 = (uint32_t *)buf;
		*p32 = BSWAP32(*p32);
	}

	put_data(buf, 4);
}
开发者ID:allkhor,项目名称:godot,代码行数:12,代码来源:stream_peer.cpp


示例19: ProcessIO

/********************************************************************
 *	モニタコマンド受信と実行.
 ********************************************************************
 */
void ProcessIO(void)
{
	// 返答パケットが空であること、かつ、
	// 処理対象の受信データがある.
	{	//if((ToPcRdy == 0)) {
		//受信データがあれば、受信データを受け取る.
		PacketToPC.raw[0]=Cmd0;		// CMD ECHOBACK

#if	APPLICATION_MODE
#if	PICAVR_WRITER
		//コマンドに対応する処理を呼び出す.
			 if(Cmd0 >= HIDASP_PAGE_TX)  {cmd_avrspx();}	// AVRライターコマンド.
		else 
#endif
			 if(Cmd0 >= PICSPX_SETADRS24){cmd_picspx();}	// PICライターコマンド.
		else 
#endif

		switch(Cmd0) {
		 case HIDASP_PEEK: 		{cmd_peek();break;}	// メモリー読み出し.
		 case HIDASP_POKE: 		{cmd_poke();break;}	// メモリー書き込み.
		 case HIDASP_JMP: 		{cmd_exec(
		 						BSWAP32(PacketFromPC.adrs),BSWAP16(PacketFromPC.size)
		 			);
		 			break;}	// 実行.
		 case HIDASP_PAGE_ERASE:{cmd_page_erase();break;}	//Flash消去.
		 case HIDASP_PAGE_WRITE:{cmd_page_write();break;}	//Flash書込.
		 case HIDASP_FLASH_LOCK:{cmd_flash_lock();break;}	//FlashLock.
		 case HIDASP_SET_MODE:  {cmd_set_mode();break;}
		 case HIDASP_SAMPLING: 	{cmd_sampling();break;}
		 case HIDASP_TEST: 		{cmd_echo();break;}			// 接続テスト.

#if	APPLICATION_MODE
		 case HIDASP_GET_STRING:{cmd_get_string();break;}
		 case HIDASP_USER_CMD:  {cmd_user_cmd();break;}
#endif
		 default: break;
		}
	}

	// 必要なら、返答パケットをインタラプト転送(EP1)でホストPCに返却する.
	if( ToPcRdy ) {
		USBputpacket(PacketToPC.raw,PACKET_SIZE);
		ToPcRdy = 0;

		if(poll_mode!=0) {
			if(mHIDRxIsBusy()) {	//コマンドが来ない限り送り続ける.
				make_report();
			}
		}
	}
}
开发者ID:iruka-,项目名称:ARM_BOOTLOADER,代码行数:56,代码来源:monit.c


示例20: bswap_enuminfo

static void
bswap_enuminfo (void *data, int len)
{
  oss_mixer_enuminfo *ei = (oss_mixer_enuminfo *) data;

  int i;

  if (len != sizeof (*ei))
    {
      fprintf (stderr, "bswap_enuminfo: Bad size (%d/%lu)\n", len,
	       (unsigned long)sizeof (*ei));
      exit (EXIT_FAILURE);
    }

  BSWAP32 (ei->dev);
  BSWAP32 (ei->ctrl);
  BSWAP32 (ei->nvalues);
  BSWAP32 (ei->version);

  for (i = 0; i < OSS_ENUM_MAXVALUE; i++)
    BSWAP32 (ei->strindex[i]);
}
开发者ID:Open-Sound-System,项目名称:Open-Sound-System,代码行数:22,代码来源:libossmix_tcp.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BSWAP_64函数代码示例发布时间:2022-05-30
下一篇:
C++ BSTR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap