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


C++ bswap32函数代码示例

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


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

示例1: krb5_ret_int32

krb5_error_code KRB5_LIB_FUNCTION
krb5_ret_int32(krb5_storage *sp,
	       int32_t *value)
{
    krb5_error_code ret = krb5_ret_int(sp, value, 4);
    if(ret)
	return ret;
    if(BYTEORDER_IS_HOST(sp))
	*value = htonl(*value);
    else if(BYTEORDER_IS_LE(sp))
	*value = bswap32(*value);
    return 0;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:13,代码来源:store.c

示例2: pci_unin_main_config_readl

static uint32_t pci_unin_main_config_readl (void *opaque,
                                            target_phys_addr_t addr)
{
    UNINState *s = opaque;
    uint32_t val;

    val = s->config_reg;
#ifdef TARGET_WORDS_BIGENDIAN
    val = bswap32(val);
#endif
    UNIN_DPRINTF("config_readl addr " TARGET_FMT_plx " val %x\n", addr, val);

    return val;
}
开发者ID:ESOS-Lab,项目名称:VSSIM,代码行数:14,代码来源:unin_pci.c

示例3: F32IEncode

static void F32IEncode( void *outp, const uint8_t *inp, unsigned samples )
{
    const float *in = (const float *)inp;
    uint8_t *out = outp;

    for( size_t i = 0; i < samples; i++ )
    {
        union { float f; uint32_t u; char b[4]; } s;

        s.f = *(in++);
        s.u = bswap32( s.u );
        memcpy( out, s.b, 4 );
        out += 4;
    }
}
开发者ID:chouquette,项目名称:vlc,代码行数:15,代码来源:araw.c

示例4: at91_bswap_buf

static void
at91_bswap_buf(struct at91_mci_softc *sc, void * dptr, void * sptr, uint32_t memsize)
{
	uint32_t * dst = (uint32_t *)dptr;
	uint32_t * src = (uint32_t *)sptr;
	uint32_t   i;

	/*
	 * If the hardware doesn't need byte-swapping, let bcopy() do the
	 * work.  Use bounce buffer even if we don't need byteswap, since
	 * buffer may straddle a page boundry, and we don't handle
	 * multi-segment transfers in hardware.  Seen from 'bsdlabel -w' which
	 * uses raw geom access to the volume.  Greg Ansley (gja (at)
	 * ansley.com)
	 */
	if (!(sc->sc_cap & CAP_NEEDS_BYTESWAP)) {
		memcpy(dptr, sptr, memsize);
		return;
	}

	/*
	 * Nice performance boost for slightly unrolling this loop.
	 * (But very little extra boost for further unrolling it.)
	 */
	for (i = 0; i < memsize; i += 16) {
		*dst++ = bswap32(*src++);
		*dst++ = bswap32(*src++);
		*dst++ = bswap32(*src++);
		*dst++ = bswap32(*src++);
	}

	/* Mop up the last 1-3 words, if any. */
	for (i = 0; i < (memsize & 0x0F); i += 4) {
		*dst++ = bswap32(*src++);
	}
}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:36,代码来源:at91_mci.c

示例5: empb_bsr4_swap

static uint32_t
empb_bsr4_swap(bus_space_handle_t handle, bus_size_t offset)
{
	uint32_t *p;
	uint32_t x;
	bus_addr_t wp; 

	wp = empb_switch_window(empb_sc, handle);	

	p = (uint32_t*) ((empb_sc->pci_mem_win_t->base) + (handle - wp) 
	    + offset);
	x = *p;

	return bswap32(x);
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:15,代码来源:empb_bsm.c

示例6: dkcksum_target

uint16_t
dkcksum_target(struct disklabel *lp)
{
	uint16_t npartitions;

	if (lp->d_magic == DISKMAGIC)
		npartitions = lp->d_npartitions;
	else if (bswap32(lp->d_magic) == DISKMAGIC)
		npartitions = bswap16(lp->d_npartitions);
	else
		npartitions = 0;

	if (npartitions > maxpartitions)
		npartitions = 0;

	return dkcksum_sized(lp, npartitions);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:17,代码来源:bswap.c

示例7: encrypt

void _KEY1::applyKeycode(u8 modulo)
{
	encrypt(&keyCode[1]);
	encrypt(&keyCode[0]);
	
	u32 scratch[2] = {0};

	for (u32 i = 0; i <= 0x44; i += 4)			// xor with reversed byte-order (bswap)
		keyBuf[DWNUM(i)] ^= bswap32(keyCode[DWNUM(i % modulo)]);

	for (u32 i = 0; i <= 0x1040; i += 8)
	{
		encrypt(scratch);						// encrypt S (64bit) by keybuf
		keyBuf[DWNUM(i)] = scratch[1];			// write S to keybuf (first upper 32bit)
		keyBuf[DWNUM(i+4)] = scratch[0];		// write S to keybuf (then lower 32bit)
	}
}
开发者ID:BlueSplash,项目名称:svn-desmume,代码行数:17,代码来源:encrypt.cpp

示例8: empb_bswm4_swap

static void
empb_bswm4_swap(bus_space_handle_t handle, bus_size_t offset, 
    const u_int32_t *pointer, bus_size_t count)
{
	volatile uint32_t *p;
	bus_addr_t wp; 

	wp = empb_switch_window(empb_sc, handle);
	p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + 
	    (handle - wp) + offset);

	while (count > 0) {
		*p = bswap32(*pointer++);
 		amiga_bus_reorder_protect();
		--count;
	}
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:17,代码来源:empb_bsm.c

示例9: process

static void
process(lzma_check_state *check)
{
#ifdef WORDS_BIGENDIAN
	transform(check->state.sha256.state, check->buffer.u32);

#else
	uint32_t data[16];
	size_t i;

	for (i = 0; i < 16; ++i)
		data[i] = bswap32(check->buffer.u32[i]);

	transform(check->state.sha256.state, data);
#endif

	return;
}
开发者ID:Anomalous-Software,项目名称:CMake,代码行数:18,代码来源:sha256.c

示例10: aml_alloc

/* ACPI 1.0b: 15.2.3.6.4.1 EISAID Macro - Convert EISA ID String To Integer */
Aml *aml_eisaid(const char *str)
{
    Aml *var = aml_alloc();
    uint32_t id;

    g_assert(strlen(str) == 7);
    id = (str[0] - 0x40) << 26 |
    (str[1] - 0x40) << 21 |
    (str[2] - 0x40) << 16 |
    Hex2Digit(str[3]) << 12 |
    Hex2Digit(str[4]) << 8 |
    Hex2Digit(str[5]) << 4 |
    Hex2Digit(str[6]);

    build_append_byte(var->buf, 0x0C); /* DWordPrefix */
    build_append_int_noprefix(var->buf, bswap32(id), sizeof(id));
    return var;
}
开发者ID:J-Liu,项目名称:qemu,代码行数:19,代码来源:aml-build.c

示例11: sizeof

struct atsc_ett_section *atsc_ett_section_codec(struct atsc_section_psip *psip)
{
	uint8_t * buf = (uint8_t *) psip;
	size_t pos = sizeof(struct atsc_section_psip);
	size_t len = section_ext_length(&(psip->ext_head));

	if (len < sizeof(struct atsc_ett_section))
		return NULL;

	bswap32(buf + pos);
	pos += 4;

	if (atsc_text_validate(buf + pos,
	    		       section_ext_length(&psip->ext_head) - sizeof(struct atsc_ett_section)))
		return NULL;

	return (struct atsc_ett_section *) psip;
}
开发者ID:felipemogollon,项目名称:dvb,代码行数:18,代码来源:ett_section.c

示例12: swap

void
MsgDialog :: swap(uint8_t* aBuf) const
{
    ASSERT(aBuf != nullptr);

    MsgInfo* info = (MsgInfo*)aBuf;

    if (info->Action == ACTION_TASKID)
    {
        info->TaskId = bswap32(info->TaskId);
    }
    else
    {
        info->PosX = bswap16(info->PosX);
        info->PosY = bswap16(info->PosY);
    }
    info->Data = bswap16(info->Data);
}
开发者ID:COPS-Projects,项目名称:Faith-Emulator,代码行数:18,代码来源:msgdialog.cpp

示例13: fw_cfg_setup

void fw_cfg_setup(void)
{
	int i, n;

	fw_cfg_select(FW_CFG_ID);
	version = fw_cfg_readl_le();

	fw_cfg_select(FW_CFG_FILE_DIR);
	n = fw_cfg_readl_be();
	filecnt = n;
	files = malloc_fseg(sizeof(files[0]) * n);

	fw_cfg_read(files, sizeof(files[0]) * n);
	for (i = 0; i < n; i++) {
		struct fw_cfg_file *f = &files[i];
		f->size = bswap32(f->size);
		f->select = bswap16(f->select);
	}
}
开发者ID:bonzini,项目名称:qboot,代码行数:19,代码来源:fw_cfg.c

示例14: endian_fix32

static inline void endian_fix32(uint32_t * tofix, size_t count) {
    /* bFLT is always big endian */

    /* endianness test */
    union {
        uint16_t int_val;
        uint8_t  char_val[2];
    } endian;
    endian.int_val = 1;

    if (endian.char_val[0]) {
        /* we are little endian, do a byteswap */
        size_t i;
        for (i=0; i<count; i++) {
            tofix[i] = bswap32(tofix[i]);
        }
    }

}
开发者ID:tangrs,项目名称:ndless-bflt-loader,代码行数:19,代码来源:bflt.c

示例15: sizeof

struct atsc_stt_section *atsc_stt_section_codec(struct atsc_section_psip *psip)
{
	uint8_t *buf = (uint8_t *) psip;
	size_t pos = sizeof(struct atsc_section_psip);
	size_t len = section_ext_length(&(psip->ext_head));

	if (len < sizeof(struct atsc_stt_section))
		return NULL;

	bswap32(buf + pos);
	pos += 5;
	bswap16(buf + pos);
	pos += 2;

	if (verify_descriptors(buf + pos, len - sizeof(struct atsc_stt_section)))
		return NULL;

	return (struct atsc_stt_section *) psip;
}
开发者ID:AntennasDirect,项目名称:dvb-apps-android,代码行数:19,代码来源:stt_section.c


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