本文整理汇总了C++中bswap_32函数的典型用法代码示例。如果您正苦于以下问题:C++ bswap_32函数的具体用法?C++ bswap_32怎么用?C++ bswap_32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bswap_32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: __glXPointParameterfvReqSize
int
__glXPointParameterfvReqSize( const GLbyte * pc, Bool swap )
{
GLenum pname = * (GLenum *)(pc + 0);
GLsizei compsize;
if (swap) {
pname = bswap_32(pname);
}
compsize = __glPointParameterfv_size(pname);
return __GLX_PAD((compsize * 4));
}
开发者ID:sheldonrobinson,项目名称:VcXsrv,代码行数:13,代码来源:indirect_reqsize.c
示例2: __glXConvolutionParameterfvReqSize
int
__glXConvolutionParameterfvReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLenum pname = * (GLenum *)(pc + 4);
GLsizei compsize;
if (swap) {
pname = bswap_32(pname);
}
compsize = __glConvolutionParameterfv_size(pname);
return safe_pad(safe_mul(compsize , 4));
}
开发者ID:theqvd,项目名称:vcxsrv,代码行数:13,代码来源:indirect_reqsize.c
示例3: __glXTexGenfvReqSize
int
__glXTexGenfvReqSize( const GLbyte * pc, Bool swap )
{
GLenum pname = * (GLenum *)(pc + 4);
GLsizei compsize;
if (swap) {
pname = bswap_32(pname);
}
compsize = __glTexGenfv_size(pname);
return __GLX_PAD((compsize * 4));
}
开发者ID:sheldonrobinson,项目名称:VcXsrv,代码行数:13,代码来源:indirect_reqsize.c
示例4: __glXFogfvReqSize
int
__glXFogfvReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLenum pname = * (GLenum *)(pc + 0);
GLsizei compsize;
if (swap) {
pname = bswap_32(pname);
}
compsize = __glFogfv_size(pname);
return safe_pad(safe_mul(compsize , 4));
}
开发者ID:theqvd,项目名称:vcxsrv,代码行数:13,代码来源:indirect_reqsize.c
示例5: mp_get_chroma_shift
int mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits)
{
int xs = 0, ys = 0;
int bpp;
int err = 0;
int bits = 8;
if ((format & 0xff0000f0) == 0x34000050)
format = bswap_32(format);
if ((format & 0xf00000ff) == 0x50000034) {
switch (format >> 24) {
case 0x50:
break;
case 0x51:
bits = 16;
break;
case 0x52:
bits = 10;
break;
case 0x53:
bits = 9;
break;
default:
err = 1;
break;
}
switch (format & 0x00ffffff) {
case 0x00343434: // 444
xs = 0;
ys = 0;
break;
case 0x00323234: // 422
xs = 1;
ys = 0;
break;
case 0x00303234: // 420
xs = 1;
ys = 1;
break;
case 0x00313134: // 411
xs = 2;
ys = 0;
break;
case 0x00303434: // 440
xs = 0;
ys = 1;
break;
default:
err = 1;
break;
}
} else switch (format) {
开发者ID:HermiG,项目名称:mplayer2,代码行数:51,代码来源:img_format.c
示例6: bswap_32
Bool16 QTAtom::ReadInt32To64Signed(UInt64 Offset, SInt64 * Datum)
{
// General vars
UInt32 tempDatum;
//
// Read and flip.
if( !ReadBytes(Offset, (char *)&tempDatum, 4) )
return false;
tempDatum = bswap_32(tempDatum);
*Datum = (SInt64) (SInt32) tempDatum;
return true;
}
开发者ID:AntoineHus,项目名称:dss,代码行数:14,代码来源:QTAtom.cpp
示例7: rhash_swap_copy_str_to_u32
/**
* Copy a memory block with simultaneous exchanging byte order.
* The byte order is changed from little-endian 32-bit integers
* to big-endian (or vice-versa).
*
* @param to the pointer where to copy memory block
* @param index the index to start writing from
* @param from the source block to copy
* @param length length of the memory block
*/
void rhash_swap_copy_str_to_u32(void* to, int index, const void* from, size_t length)
{
/* if all pointers and length are 32-bits aligned */
if ( 0 == (( (int)((char*)to - (char*)0) | ((char*)from - (char*)0) | index | length ) & 3) ) {
/* copy memory as 32-bit words */
const uint32_t* src = (const uint32_t*)from;
const uint32_t* end = (const uint32_t*)((const char*)src + length);
uint32_t* dst = (uint32_t*)((char*)to + index);
while (src < end) *(dst++) = bswap_32( *(src++) );
} else {
const char* src = (const char*)from;
for (length += index; (size_t)index < length; index++) ((char*)to)[index ^ 3] = *(src++);
}
}
开发者ID:AutomationInnwpu,项目名称:mentohust,代码行数:24,代码来源:byte_order.c
示例8: __glXBitmapReqSize
int
__glXBitmapReqSize( const GLbyte * pc, Bool swap )
{
GLint row_length = * (GLint *)(pc + 4);
GLint image_height = 0;
GLint skip_images = 0;
GLint skip_rows = * (GLint *)(pc + 8);
GLint alignment = * (GLint *)(pc + 16);
GLsizei width = *(GLsizei *)(pc + 20);
GLsizei height = *(GLsizei *)(pc + 24);
if (swap) {
row_length = bswap_32(row_length);
skip_rows = bswap_32(skip_rows);
alignment = bswap_32(alignment);
width = bswap_32(width);
height = bswap_32(height);
}
return __glXImageSize(GL_COLOR_INDEX, GL_BITMAP, 0, width, height, 1,
image_height, row_length, skip_images,
skip_rows, alignment);
}
开发者ID:sheldonrobinson,项目名称:VcXsrv,代码行数:23,代码来源:indirect_reqsize.c
示例9: ocfs2_swap_group_desc
void ocfs2_swap_group_desc(struct ocfs2_group_desc *gd)
{
if (cpu_is_little_endian)
return;
gd->bg_size = bswap_16(gd->bg_size);
gd->bg_bits = bswap_16(gd->bg_bits);
gd->bg_free_bits_count = bswap_16(gd->bg_free_bits_count);
gd->bg_chain = bswap_16(gd->bg_chain);
gd->bg_generation = bswap_32(gd->bg_generation);
gd->bg_next_group = bswap_64(gd->bg_next_group);
gd->bg_parent_dinode = bswap_64(gd->bg_parent_dinode);
gd->bg_blkno = bswap_64(gd->bg_blkno);
}
开发者ID:ystk,项目名称:debian-ocfs2-tools,代码行数:14,代码来源:chain.c
示例10:
Bool16 QTAtom::ReadInt32(UInt64 Offset, UInt32 * Datum)
{
// General vars
UInt32 tempDatum;
//
// Read and flip.
if( !ReadBytes(Offset, (char *)&tempDatum, 4) )
return false;
*Datum = bswap_32(tempDatum);
return true;
}
开发者ID:AntoineHus,项目名称:dss,代码行数:14,代码来源:QTAtom.cpp
示例11: fulltest
int fulltest(const unsigned char *hash, const unsigned char *target)
{
uint32_t *hash32 = (uint32_t *)hash;
uint32_t *target32 = (uint32_t *)target;
int rc = 1;
int i;
for (i = 28 / 4; i >= 0; i--) {
uint32_t h32tmp = bswap_32(hash32[i]);
uint32_t t32tmp = bswap_32(target32[i]);
if (h32tmp > t32tmp) {
rc = NONCE_VALID;
break;
}
if (h32tmp < t32tmp) {
rc = NONCE_DIFF;
break;
}
}
return rc;
}
开发者ID:HashRatio,项目名称:mm-hashratio,代码行数:23,代码来源:miner.c
示例12: errormsg
char* errormsg(int* sbufLen,uint32_t transaction_id,char* error_msg) {
int32_t action;
int msgLen;
action=3;
msgLen = strlen(error_msg);
*sbufLen = msgLen+8;
char* sbuffer = malloc(*sbufLen);
/* convert them to network order */
#ifdef LITTLE_ENDIAN
action = bswap_32(action);
transaction_id = bswap_32(transaction_id);
#endif
memcpy(sbuffer,&action,4);
memcpy(sbuffer+4,&transaction_id,4);
memcpy(sbuffer+8,&error_msg,msgLen);
LOGMSG(LOG_INFO,"ERRORTransaction ID: %u Text: %s",transaction_id,error_msg);
return sbuffer;
}
开发者ID:n0g,项目名称:racker,代码行数:24,代码来源:actions.c
示例13: LD_FILE_GETWORD
Word LD_FILE_GETWORD()
{
Word tmp;
if(sizeof(tmp)!=read(fd,&tmp,sizeof(tmp)))
EM_THROW(LD_FILE_ReadError);
#if BYTE_ORDER == LITTLE_ENDIAN
# if __WORDSIZE == 32
return (Word)bswap_32((unsigned int)tmp);
# elif __WORDSIZE == 64
return bswap_64(tmp);
# endif
#elif BYTE_ORDER == BIG_ENDIAN
return tmp;
#endif
}
开发者ID:Angeldude,项目名称:teyjus,代码行数:15,代码来源:file.c
示例14: ParcelDtor
/* de-serialize channels data from the parcel. return number of sources */
static int ParcelDtor(struct Manifest *manifest, char *parcel)
{
struct NSParcel *p = (void*)parcel;
int64_t end = bswap_32(p->bind_number) + bswap_32(p->connect_number);
int64_t m = 0, n = 0;
int64_t i;
/* update channels sources from the parcel */
for(i = 0; i < end; ++i)
{
struct Connection *c;
NEXT_SRC();
/* skip "binds" */
if(i < bswap_32(p->bind_number)) continue;
/* ip is already in network format for inet_ntoa */
c->host = p->records[i].host;
c->port = bswap_16(p->records[i].port);
}
g_free(parcel);
return end;
}
开发者ID:painterjd,项目名称:zerovm-2.0,代码行数:25,代码来源:nservice.c
示例15: bswap_32
void DeepStarComponent::byteSwap( starData *stardata ) {
stardata->RA = bswap_32( stardata->RA );
stardata->Dec = bswap_32( stardata->Dec );
stardata->dRA = bswap_32( stardata->dRA );
stardata->dDec = bswap_32( stardata->dDec );
stardata->parallax = bswap_32( stardata->parallax );
stardata->HD = bswap_32( stardata->HD );
stardata->mag = bswap_16( stardata->mag );
stardata->bv_index = bswap_16( stardata->bv_index );
}
开发者ID:KDE,项目名称:kstars,代码行数:10,代码来源:deepstarcomponent.cpp
示例16: bswap_32
void FirewirePort::StopCycleStartPacket(void)
{
// IMPORTANT: Disable Cycle Start Packet, no isochronous
int rc = 0; // return code
quadlet_t data_stop_cmc = bswap_32(0x100);
rc = raw1394_write(handle,
raw1394_get_local_id(handle),
CSR_REGISTER_BASE + CSR_STATE_CLEAR,
4,
&data_stop_cmc);
if (rc) {
outStr << "*****Error: can NOT disable cycle start packet" << std::endl;
} else {
outStr << "FirewirePort: successfully disabled cycle start packet" << std::endl;
}
}
开发者ID:samzer2,项目名称:mechatronics-software,代码行数:16,代码来源:FirewirePort.cpp
示例17: u32_swap_copy
/**
* Copy a memory block with simultanious exchanging byte order.
* The byte order is changed from little-endian 32-bit integers
* to big-endian (or vice-versa).
*
* @param to the pointer where to copy memory block
* @param from the source block to copy
* @param length length of the memory block
*/
void u32_swap_copy(void* to, const void* from, size_t length)
{
// if all pointers and length are 32-bits aligned
if( 0 == (( (int)((char*)to - (char*)0) | ((char*)from - (char*)0) | length ) & 3) ) {
/* copy memory as dwords */
const unsigned* src = (const unsigned*)from;
const unsigned* end = (const unsigned*)((const char*)src + length);
unsigned* dst = (unsigned*)to;
while(src<end) *(dst++) = bswap_32( *(src++) );
} else {
int index = (int)((char*)to - (char*)0) & 3;
const char* src = (const char*)from;
const char* end = src + length;
char* dst = (char*)to - index;
for(; src<end; index++) dst[index^3] = *src++;
}
}
开发者ID:master255,项目名称:SimplyServer,代码行数:26,代码来源:byte_order.c
示例18: get_local_address
int get_local_address(int skt, int *port) {
#if !defined(sparc) && !defined(SGI) && !defined(WIN32)
unsigned
#endif
int nAddrSize = sizeof(struct sockaddr_in);
struct sockaddr_in remAddr;
int status;
remAddr.sin_addr.s_addr = INADDR_ANY;
status = getsockname(skt, (struct sockaddr*)&remAddr, &nAddrSize);
if (status >= 0)
{
if (port)
*port = bswap_16(remAddr.sin_port);
return bswap_32(remAddr.sin_addr.s_addr);
}
return -1;
}
开发者ID:AntoineHus,项目名称:dss,代码行数:17,代码来源:proxy_unix.c
示例19: stream_head_read
LOCAL int stream_head_read(unsigned char *hbuf,uint32_t *newhead){
if(mp3_read(hbuf,4) != 4) return FALSE;
#ifdef ARCH_X86
*newhead = bswap_32(*((uint32_t*)hbuf));
#else
/*
* we may not be able to address unaligned 32-bit data on non-x86 cpus.
* Fall back to some portable code.
*/
*newhead =
hbuf[0] << 24 |
hbuf[1] << 16 |
hbuf[2] << 8 |
hbuf[3];
#endif
return TRUE;
}
开发者ID:twtwft,项目名称:mplayer-10rc2-upgrade,代码行数:17,代码来源:sr1.c
示例20: recv_udp
int recv_udp(int socket, char *buf, int amt, int *fromip, int *fromport)
{
struct sockaddr_in sin;
int ret;
unsigned int len;
len = sizeof(sin);
memset(&sin, 0, sizeof(sin));
ret = recvfrom(socket, buf, (size_t) amt, 0, (struct sockaddr*)&sin, &len);
if (ret != -1) {
if (fromip)
*fromip = bswap_32(sin.sin_addr.s_addr);
if (fromport)
*fromport = bswap_16(sin.sin_port);
}
return ret;
}
开发者ID:AntoineHus,项目名称:dss,代码行数:17,代码来源:proxy_unix.c
注:本文中的bswap_32函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论