Android-cuttlefish cvd tool
Namespaces | Macros | Functions
cf_endian.h File Reference
#include <inttypes.h>
#include <android-base/endian.h>
Include dependency graph for cf_endian.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  cuttlefish
 

Macros

#define DECLARE_TYPE(new_type, base_type, to_new, to_base)
 

Functions

 cuttlefish::DECLARE_TYPE (Le16, uint16_t, htole16, le16toh)
 
 cuttlefish::DECLARE_TYPE (Le32, uint32_t, htole32, le32toh)
 
 cuttlefish::DECLARE_TYPE (Le64, uint64_t, htole64, le64toh)
 
 cuttlefish::DECLARE_TYPE (Be16, uint16_t, htobe16, be16toh)
 
 cuttlefish::DECLARE_TYPE (Be32, uint32_t, htobe32, be32toh)
 
 cuttlefish::DECLARE_TYPE (Be64, uint64_t, htobe64, be64toh)
 

Macro Definition Documentation

◆ DECLARE_TYPE

#define DECLARE_TYPE (   new_type,
  base_type,
  to_new,
  to_base 
)
Value:
class new_type { \
public: \
new_type() = default; \
explicit new_type(base_type val) : inner_(to_new(val)) {} \
new_type(const new_type&) = default; \
new_type& operator=(const new_type& other) = default; \
volatile new_type& operator=(const new_type& other) volatile { \
inner_ = other.inner_; \
return *this; \
} \
base_type as_##base_type() const volatile { return to_base(inner_); } \
\
private: \
base_type inner_; \
}; \
static_assert(sizeof(new_type) == sizeof(base_type))