]>
git.proxmox.com Git - ceph.git/blob - ceph/src/include/byteorder.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
5 #include <boost/endian/conversion.hpp>
10 inline T
swab(T val
) {
11 return boost::endian::endian_reverse(val
);
20 explicit ceph_le(T nv
)
21 : v
{boost::endian::native_to_little(nv
)}
23 ceph_le
<T
>& operator=(T nv
) {
24 v
= boost::endian::native_to_little(nv
);
27 operator T() const { return boost::endian::little_to_native(v
); }
28 friend inline bool operator==(ceph_le a
, ceph_le b
) {
31 } __attribute__ ((packed
));
33 using ceph_le64
= ceph_le
<__u64
>;
34 using ceph_le32
= ceph_le
<__u32
>;
35 using ceph_le16
= ceph_le
<__u16
>;
37 using ceph_les64
= ceph_le
<__s64
>;
38 using ceph_les32
= ceph_le
<__s32
>;
39 using ceph_les16
= ceph_le
<__s16
>;
41 inline ceph_les64
init_les64(__s64 x
) {
46 inline ceph_les32
init_les32(__s32 x
) {
51 inline ceph_les16
init_les16(__s16 x
) {