本文整理汇总了C++中BSWAP_64函数的典型用法代码示例。如果您正苦于以下问题:C++ BSWAP_64函数的具体用法?C++ BSWAP_64怎么用?C++ BSWAP_64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BSWAP_64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zap_leaf_byteswap
void
zap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
{
int i;
zap_leaf_t l;
dmu_buf_t l_dbuf;
l_dbuf.db_data = buf;
l.l_bs = highbit64(size) - 1;
l.l_dbuf = &l_dbuf;
buf->l_hdr.lh_block_type = BSWAP_64(buf->l_hdr.lh_block_type);
buf->l_hdr.lh_prefix = BSWAP_64(buf->l_hdr.lh_prefix);
buf->l_hdr.lh_magic = BSWAP_32(buf->l_hdr.lh_magic);
buf->l_hdr.lh_nfree = BSWAP_16(buf->l_hdr.lh_nfree);
buf->l_hdr.lh_nentries = BSWAP_16(buf->l_hdr.lh_nentries);
buf->l_hdr.lh_prefix_len = BSWAP_16(buf->l_hdr.lh_prefix_len);
buf->l_hdr.lh_freelist = BSWAP_16(buf->l_hdr.lh_freelist);
for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(&l); i++)
buf->l_hash[i] = BSWAP_16(buf->l_hash[i]);
for (i = 0; i < ZAP_LEAF_NUMCHUNKS(&l); i++) {
zap_leaf_chunk_t *lc = &ZAP_LEAF_CHUNK(&l, i);
struct zap_leaf_entry *le;
switch (lc->l_free.lf_type) {
case ZAP_CHUNK_ENTRY:
le = &lc->l_entry;
le->le_type = BSWAP_8(le->le_type);
le->le_value_intlen = BSWAP_8(le->le_value_intlen);
le->le_next = BSWAP_16(le->le_next);
le->le_name_chunk = BSWAP_16(le->le_name_chunk);
le->le_name_numints = BSWAP_16(le->le_name_numints);
le->le_value_chunk = BSWAP_16(le->le_value_chunk);
le->le_value_numints = BSWAP_16(le->le_value_numints);
le->le_cd = BSWAP_32(le->le_cd);
le->le_hash = BSWAP_64(le->le_hash);
break;
case ZAP_CHUNK_FREE:
lc->l_free.lf_type = BSWAP_8(lc->l_free.lf_type);
lc->l_free.lf_next = BSWAP_16(lc->l_free.lf_next);
break;
case ZAP_CHUNK_ARRAY:
lc->l_array.la_type = BSWAP_8(lc->l_array.la_type);
lc->l_array.la_next = BSWAP_16(lc->l_array.la_next);
/* la_array doesn't need swapping */
break;
default:
cmn_err(CE_PANIC, "bad leaf type %d",
lc->l_free.lf_type);
}
}
}
示例2: zio_checksum_edonr_byteswap
/*
* Byteswapped zio_checksum interface for the Edon-R hash function.
*/
static void
zio_checksum_edonr_byteswap(const void *buf, uint64_t size,
const void *ctx_template, zio_cksum_t *zcp)
{
zio_cksum_t tmp;
zio_checksum_edonr_native(buf, size, ctx_template, &tmp);
zcp->zc_word[0] = BSWAP_64(zcp->zc_word[0]);
zcp->zc_word[1] = BSWAP_64(zcp->zc_word[1]);
zcp->zc_word[2] = BSWAP_64(zcp->zc_word[2]);
zcp->zc_word[3] = BSWAP_64(zcp->zc_word[3]);
}
示例3: abd_checksum_edonr_byteswap
/*
* Byteswapped zio_checksum interface for the Edon-R hash function.
*/
void
abd_checksum_edonr_byteswap(abd_t *abd, uint64_t size,
const void *ctx_template, zio_cksum_t *zcp)
{
zio_cksum_t tmp;
abd_checksum_edonr_native(abd, size, ctx_template, &tmp);
zcp->zc_word[0] = BSWAP_64(zcp->zc_word[0]);
zcp->zc_word[1] = BSWAP_64(zcp->zc_word[1]);
zcp->zc_word[2] = BSWAP_64(zcp->zc_word[2]);
zcp->zc_word[3] = BSWAP_64(zcp->zc_word[3]);
}
示例4: mzap_byteswap
static void
mzap_byteswap(mzap_phys_t *buf, size_t size)
{
int i, maximum;
buf->mz_block_type = BSWAP_64(buf->mz_block_type);
buf->mz_salt = BSWAP_64(buf->mz_salt);
maximum = (size / MZAP_ENT_LEN) - 1;
for (i = 0; i < maximum; i++) {
buf->mz_chunk[i].mze_value =
BSWAP_64(buf->mz_chunk[i].mze_value);
buf->mz_chunk[i].mze_cd =
BSWAP_32(buf->mz_chunk[i].mze_cd);
}
}
示例5: dmu_objset_byteswap
void
dmu_objset_byteswap(void *buf, size_t size)
{
objset_phys_t *osp = buf;
ASSERT(size == OBJSET_OLD_PHYS_SIZE || size == sizeof (objset_phys_t));
dnode_byteswap(&osp->os_meta_dnode);
byteswap_uint64_array(&osp->os_zil_header, sizeof (zil_header_t));
osp->os_type = BSWAP_64(osp->os_type);
osp->os_flags = BSWAP_64(osp->os_flags);
if (size == sizeof (objset_phys_t)) {
dnode_byteswap(&osp->os_userused_dnode);
dnode_byteswap(&osp->os_groupused_dnode);
}
}
示例6: fletcher_2_byteswap
void
fletcher_2_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
{
const uint64_t *ip = buf;
const uint64_t *ipend = ip + (size / sizeof (uint64_t));
uint64_t a0, b0, a1, b1;
for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
a0 += BSWAP_64(ip[0]);
a1 += BSWAP_64(ip[1]);
b0 += a0;
b1 += a1;
}
ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
}
示例7: test_bo
// 测试位操作
void test_bo(uint64_t i) {
uint64_t r;
uint32_t count;
count = OP_COUNT;
while (count--) {
r = BSWAP_64(i);
}
printf("bo result is %llu\n", r);
}
示例8: dmu_objset_byteswap
void
dmu_objset_byteswap(void *buf, size_t size)
{
objset_phys_t *osp = buf;
ASSERT(size == sizeof (objset_phys_t));
dnode_byteswap(&osp->os_meta_dnode);
byteswap_uint64_array(&osp->os_zil_header, sizeof (zil_header_t));
osp->os_type = BSWAP_64(osp->os_type);
}
示例9: uberblock_verify
int
uberblock_verify(uberblock_t *ub)
{
if (ub->ub_magic == BSWAP_64((uint64_t)UBERBLOCK_MAGIC))
byteswap_uint64_array(ub, sizeof (uberblock_t));
if (ub->ub_magic != UBERBLOCK_MAGIC)
return (SET_ERROR(EINVAL));
return (0);
}
示例10: fzap_byteswap
void
fzap_byteswap(void *vbuf, size_t size)
{
uint64_t block_type = *(uint64_t *)vbuf;
if (block_type == ZBT_LEAF || block_type == BSWAP_64(ZBT_LEAF))
zap_leaf_byteswap(vbuf, size);
else {
/* it's a ptrtbl block */
byteswap_uint64_array(vbuf, size);
}
}
示例11: zap_byteswap
void
zap_byteswap(void *buf, size_t size)
{
uint64_t block_type;
block_type = *(uint64_t *)buf;
if (block_type == ZBT_MICRO || block_type == BSWAP_64(ZBT_MICRO)) {
/* ASSERT(magic == ZAP_LEAF_MAGIC); */
mzap_byteswap(buf, size);
} else {
fzap_byteswap(buf, size);
}
}
示例12: fletcher_2_incremental_byteswap
int
fletcher_2_incremental_byteswap(void *buf, size_t size, void *data)
{
zio_cksum_t *zcp = data;
const uint64_t *ip = buf;
const uint64_t *ipend = ip + (size / sizeof (uint64_t));
uint64_t a0, b0, a1, b1;
a0 = zcp->zc_word[0];
a1 = zcp->zc_word[1];
b0 = zcp->zc_word[2];
b1 = zcp->zc_word[3];
for (; ip < ipend; ip += 2) {
a0 += BSWAP_64(ip[0]);
a1 += BSWAP_64(ip[1]);
b0 += a0;
b1 += a1;
}
ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
return (0);
}
示例13: test_swap_double
static void test_swap_double() {
union {
double d;
uint64_t u;
} ud = {
.u = 0x7856341283C0F33F
};
double x = 1.2344999991522893623141499119810760021209716796875;
ud.u = BSWAP_64(ud.u);
double r = ud.d;
if (r == x) {
printf("%.64f\n", ud.d);
printf("swap okay\n");
} else {
printf("swap failed\n");
printf("%.64f\n", ud.d);
}
double td = 1.2344999991522893623141499119810760021209716796875;
if (memcmp(&td, "\x78\x56\x34\x12\x83\xC0\xF3\x3F", 8) == 0) {
printf("little endian double\n");
} else if (memcmp(&td, "\x3F\xF3\xC0\x83\x12\x34\x56\x78", 8) == 0) {
printf("big endian double\n");
} else {
printf("not support number format to dump!");
}
}
int main(int argc, char const* argv[]) {
test_swap_double();
test_b32();
union_test();
uint64_t i = 0x123456789abcdeff;
measure_time(test_mc, i, "memory copy");
measure_time(test_mc2, i, "memory copy 2");
measure_time(test_bo, i, "bitwise operation");
return 0;
}
示例14: zio_checksum_error
int
zio_checksum_error(zio_t *zio, zio_bad_cksum_t *info)
{
blkptr_t *bp = zio->io_bp;
uint_t checksum = (bp == NULL ? zio->io_prop.zp_checksum :
(BP_IS_GANG(bp) ? ZIO_CHECKSUM_GANG_HEADER : BP_GET_CHECKSUM(bp)));
int byteswap;
int error;
uint64_t size = (bp == NULL ? zio->io_size :
(BP_IS_GANG(bp) ? SPA_GANGBLOCKSIZE : BP_GET_PSIZE(bp)));
uint64_t offset = zio->io_offset;
void *data = zio->io_data;
zio_checksum_info_t *ci = &zio_checksum_table[checksum];
zio_cksum_t actual_cksum, expected_cksum, verifier;
if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
return (EINVAL);
if (ci->ci_eck) {
zio_eck_t *eck;
if (checksum == ZIO_CHECKSUM_ZILOG2) {
zil_chain_t *zilc = data;
uint64_t nused;
eck = &zilc->zc_eck;
if (eck->zec_magic == ZEC_MAGIC)
nused = zilc->zc_nused;
else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC))
nused = BSWAP_64(zilc->zc_nused);
else
return (ECKSUM);
if (nused > size)
return (ECKSUM);
size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t);
} else {
eck = (zio_eck_t *)((char *)data + size) - 1;
}
if (checksum == ZIO_CHECKSUM_GANG_HEADER)
zio_checksum_gang_verifier(&verifier, bp);
else if (checksum == ZIO_CHECKSUM_LABEL)
zio_checksum_label_verifier(&verifier, offset);
else
verifier = bp->blk_cksum;
byteswap = (eck->zec_magic == BSWAP_64(ZEC_MAGIC));
if (byteswap)
byteswap_uint64_array(&verifier, sizeof (zio_cksum_t));
expected_cksum = eck->zec_cksum;
eck->zec_cksum = verifier;
ci->ci_func[byteswap](data, size, &actual_cksum);
eck->zec_cksum = expected_cksum;
if (byteswap)
byteswap_uint64_array(&expected_cksum,
sizeof (zio_cksum_t));
} else {
ASSERT(!BP_IS_GANG(bp));
byteswap = BP_SHOULD_BYTESWAP(bp);
expected_cksum = bp->blk_cksum;
ci->ci_func[byteswap](data, size, &actual_cksum);
}
info->zbc_expected = expected_cksum;
info->zbc_actual = actual_cksum;
info->zbc_checksum_name = ci->ci_name;
info->zbc_byteswapped = byteswap;
info->zbc_injected = 0;
info->zbc_has_cksum = 1;
if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) {
return (ECKSUM);
}
if (zio_injection_enabled && !zio->io_error &&
(error = zio_handle_fault_injection(zio, ECKSUM)) != 0) {
info->zbc_injected = 1;
return (error);
}
return (0);
}
示例15: zfs_ace_byteswap
/*
* swap ace_t and ace_oject_t
*/
void
zfs_ace_byteswap(void *buf, size_t size, boolean_t zfs_layout)
{
#ifdef TODO
caddr_t end;
caddr_t ptr;
zfs_ace_t *zacep;
ace_t *acep;
uint16_t entry_type;
size_t entry_size;
int ace_type;
end = (caddr_t)buf + size;
ptr = buf;
while (ptr < end) {
if (zfs_layout) {
zacep = (zfs_ace_t *)ptr;
zacep->z_hdr.z_access_mask =
BSWAP_32(zacep->z_hdr.z_access_mask);
zacep->z_hdr.z_flags = BSWAP_16(zacep->z_hdr.z_flags);
ace_type = zacep->z_hdr.z_type =
BSWAP_16(zacep->z_hdr.z_type);
entry_type = zacep->z_hdr.z_flags & ACE_TYPE_FLAGS;
} else {
acep = (ace_t *)ptr;
acep->a_access_mask = BSWAP_32(acep->a_access_mask);
acep->a_flags = BSWAP_16(acep->a_flags);
ace_type = acep->a_type = BSWAP_16(acep->a_type);
acep->a_who = BSWAP_32(acep->a_who);
entry_type = acep->a_flags & ACE_TYPE_FLAGS;
}
switch (entry_type) {
case ACE_OWNER:
case ACE_EVERYONE:
case (ACE_IDENTIFIER_GROUP | ACE_GROUP):
entry_size = zfs_layout ?
sizeof (zfs_ace_hdr_t) : sizeof (ace_t);
break;
case ACE_IDENTIFIER_GROUP:
default:
if (zfs_layout) {
zacep->z_fuid = BSWAP_64(zacep->z_fuid);
}
switch (ace_type) {
case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE:
case ACE_ACCESS_DENIED_OBJECT_ACE_TYPE:
case ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE:
case ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE:
entry_size = zfs_layout ?
sizeof (zfs_object_ace_t) :
sizeof (ace_object_t);
break;
default:
entry_size = zfs_layout ? sizeof (zfs_ace_t) :
sizeof (ace_t);
break;
}
}
ptr = ptr + entry_size;
}
#else /* TODO */
panic("%s:%u: TODO", __func__, __LINE__);
#endif /* TODO */
}