本文整理汇总了C++中bswap32函数的典型用法代码示例。如果您正苦于以下问题:C++ bswap32函数的具体用法?C++ bswap32怎么用?C++ bswap32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bswap32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: updateSwsFormat
bool MediaEngine::stepVideo(int videoPixelMode) {
// if video engine is broken, force to add timestamp
m_videopts += 3003;
#ifdef USE_FFMPEG
updateSwsFormat(videoPixelMode);
// TODO: Technically we could set this to frameWidth instead of m_desWidth for better perf.
// Update the linesize for the new format too. We started with the largest size, so it should fit.
m_pFrameRGB->linesize[0] = getPixelFormatBytes(videoPixelMode) * m_desWidth;
AVFormatContext *pFormatCtx = (AVFormatContext*)m_pFormatCtx;
AVCodecContext *pCodecCtx = (AVCodecContext*)m_pCodecCtx;
AVFrame *pFrame = (AVFrame*)m_pFrame;
AVFrame *pFrameRGB = (AVFrame*)m_pFrameRGB;
if ((!m_pFrame)||(!m_pFrameRGB))
return false;
AVPacket packet;
int frameFinished;
bool bGetFrame = false;
while(av_read_frame(pFormatCtx, &packet)>=0) {
if(packet.stream_index == m_videoStream) {
// Decode video frame
avcodec_decode_video2(pCodecCtx, m_pFrame, &frameFinished, &packet);
sws_scale(m_sws_ctx, m_pFrame->data, m_pFrame->linesize, 0,
pCodecCtx->height, m_pFrameRGB->data, m_pFrameRGB->linesize);
if(frameFinished) {
int firstTimeStamp = bswap32(*(int*)(m_pdata + 86));
m_videopts = pFrame->pkt_dts + pFrame->pkt_duration - firstTimeStamp;
bGetFrame = true;
}
}
av_free_packet(&packet);
if (bGetFrame) break;
}
if (!bGetFrame && m_readSize >= m_streamSize)
m_isVideoEnd = true;
return bGetFrame;
#else
return true;
#endif // USE_FFMPEG
}
开发者ID:jack00,项目名称:ppsspp,代码行数:42,代码来源:MediaEngine.cpp
示例17: pci_cfg_read_32bit
static uint32_t
pci_cfg_read_32bit(uint32_t addr)
{
uint32_t temp = 0;
uint32_t *p = (uint32_t *)xlr_pci_config_base + addr / sizeof(uint32_t);
uint64_t cerr_cpu_log = 0;
disable_and_clear_cache_error();
temp = bswap32(*p);
/* Read cache err log */
cerr_cpu_log = read_xlr_ctrl_register(CPU_BLOCKID_LSU,
LSU_CERRLOG_REGID);
if (cerr_cpu_log) {
/* Device don't exist. */
temp = ~0x0;
}
clear_and_enable_cache_error();
return (temp);
}
开发者ID:BillTheBest,项目名称:libuinet,代码行数:20,代码来源:xlr_pci.c
示例18: setup_openpic_ipi
void
setup_openpic_ipi(void)
{
uint32_t x;
ipiops.ppc_send_ipi = openpic_send_ipi;
ipiops.ppc_establish_ipi = openpic_establish_ipi;
ipiops.ppc_ipi_vector = IPI_VECTOR;
/* Some (broken) openpic's byteswap on read, but not write. */
openpic_write(OPENPIC_IPI_VECTOR(0), OPENPIC_IMASK);
x = openpic_read(OPENPIC_IPI_VECTOR(0));
if (x != OPENPIC_IMASK)
x = bswap32(openpic_read(OPENPIC_IPI_VECTOR(1)));
else
x = openpic_read(OPENPIC_IPI_VECTOR(1));
x &= ~(OPENPIC_IMASK | OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK);
x |= (15 << OPENPIC_PRIORITY_SHIFT) | ipiops.ppc_ipi_vector;
openpic_write(OPENPIC_IPI_VECTOR(1), x);
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:20,代码来源:ipi_openpic.c
示例19: sizeof
int MediaEngine::addStreamData(u8* buffer, int addSize) {
int size = addSize;
if (size > 0 && m_pdata) {
if (!m_pdata->push(buffer, size))
size = 0;
if (m_demux) {
m_demux->addStreamData(buffer, addSize);
m_demux->demux(m_audioStream);
}
#ifdef USE_FFMPEG
if (!m_pFormatCtx) {
m_pdata->get_front(m_mpegheader, sizeof(m_mpegheader));
int mpegoffset = bswap32(*(int*)(m_mpegheader + 8));
m_pdata->pop_front(0, mpegoffset);
openContext();
}
#endif // USE_FFMPEG
}
return size;
}
开发者ID:artart78,项目名称:ppsspp,代码行数:20,代码来源:MediaEngine.cpp
示例20: hammer2_bswap_head
/*
* This swaps endian for a hammer2_msg_hdr. Note that the extended
* header is not adjusted, just the core header.
*/
void
hammer2_bswap_head(hammer2_msg_hdr_t *head)
{
head->magic = bswap16(head->magic);
head->reserved02 = bswap16(head->reserved02);
head->salt = bswap32(head->salt);
head->msgid = bswap64(head->msgid);
head->source = bswap64(head->source);
head->target = bswap64(head->target);
head->cmd = bswap32(head->cmd);
head->aux_crc = bswap32(head->aux_crc);
head->aux_bytes = bswap32(head->aux_bytes);
head->error = bswap32(head->error);
head->aux_descr = bswap64(head->aux_descr);
head->reserved38= bswap32(head->reserved38);
head->hdr_crc = bswap32(head->hdr_crc);
}
开发者ID:bradla,项目名称:hammerfs2,代码行数:23,代码来源:subs.c
注:本文中的bswap32函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论