libfoedus-core
FOEDUS Core Library
endianness.hpp File Reference

A few macros and helper methods related to byte endian-ness. More...

Detailed Description

A few macros and helper methods related to byte endian-ness.

Big endian is preferred in places where we need memcmp correctly work. OTH, little endinan is preferred where the host machine is little endian and we want to do native integer comparison for better performance.

As a result, we use both in our code. Hence, we need to:

  • detect whether the host is big endian or little endian
  • convert big-endian to/from host-endian (which is probably little-endian).

Definition in file endianness.hpp.

#include <endian.h>
#include <stdint.h>
#include <limits>
#include "foedus/compiler.hpp"
Include dependency graph for endianness.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 foedus
 Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
 
 foedus::assorted
 Assorted Methods/Classes that are too subtle to have their own packages.
 

Functions

template<typename T >
foedus::assorted::betoh (T be_value)
 
template<>
uint64_t foedus::assorted::betoh< uint64_t > (uint64_t be_value)
 
template<>
uint32_t foedus::assorted::betoh< uint32_t > (uint32_t be_value)
 
template<>
uint16_t foedus::assorted::betoh< uint16_t > (uint16_t be_value)
 
template<>
uint8_t foedus::assorted::betoh< uint8_t > (uint8_t be_value)
 
template<>
int64_t foedus::assorted::betoh< int64_t > (int64_t be_value)
 
template<>
int32_t foedus::assorted::betoh< int32_t > (int32_t be_value)
 
template<>
int16_t foedus::assorted::betoh< int16_t > (int16_t be_value)
 
template<>
int8_t foedus::assorted::betoh< int8_t > (int8_t be_value)
 
template<typename T >
foedus::assorted::htobe (T host_value)
 
template<>
uint64_t foedus::assorted::htobe< uint64_t > (uint64_t host_value)
 
template<>
uint32_t foedus::assorted::htobe< uint32_t > (uint32_t host_value)
 
template<>
uint16_t foedus::assorted::htobe< uint16_t > (uint16_t host_value)
 
template<>
uint8_t foedus::assorted::htobe< uint8_t > (uint8_t host_value)
 
template<>
int64_t foedus::assorted::htobe< int64_t > (int64_t host_value)
 
template<>
int32_t foedus::assorted::htobe< int32_t > (int32_t host_value)
 
template<>
int16_t foedus::assorted::htobe< int16_t > (int16_t host_value)
 
template<>
int8_t foedus::assorted::htobe< int8_t > (int8_t host_value)
 
template<typename T >
foedus::assorted::read_bigendian (const void *be_bytes)
 Convert a big-endian byte array to a native integer. More...
 
template<typename T >
void foedus::assorted::write_bigendian (T host_value, void *be_bytes)
 Convert a native integer to big-endian bytes and write them to the given address. More...
 

Variables

const bool foedus::assorted::kIsLittleEndian = false
 A handy const boolean to tell if it's little endina. More...