ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Namespaces | Functions
set_unaligned.h File Reference

Write little-endian values through possibly unaligned pointers. More...

#include "CxxUtils/restrict.h"
#include <cstring>
#include <bit>
#include <cstdint>
Include dependency graph for set_unaligned.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 CxxUtils
 

Functions

uint16_t CxxUtils::htole16 (uint16_t x)
 
uint32_t CxxUtils::htole32 (uint32_t x)
 
uint64_t CxxUtils::htole64 (uint64_t x)
 
void CxxUtils::set_unaligned16 (uint8_t *ATH_RESTRICT &p, uint16_t val)
 Write a 2-byte little-endian value to a possibly unaligned pointer. More...
 
void CxxUtils::set_unaligned32 (uint8_t *ATH_RESTRICT &p, uint32_t val)
 Write a 4-byte little-endian value to a possibly unaligned pointer. More...
 
void CxxUtils::set_unaligned64 (uint8_t *ATH_RESTRICT &p, uint64_t val)
 Write an 8-byte little-endian value to a possibly unaligned pointer. More...
 
void CxxUtils::set_unaligned_float (uint8_t *ATH_RESTRICT &p, float val)
 Write a little-endian float value to a possibly unaligned pointer. More...
 
void CxxUtils::set_unaligned_double (uint8_t *ATH_RESTRICT &p, double val)
 Write a little-endian double value to a possibly unaligned pointer. More...
 
template<class T >
void CxxUtils::set_unaligned (uint8_t *ATH_RESTRICT &p, T val)
 Define templated versions of the above functions. More...
 
template<>
void CxxUtils::set_unaligned< uint8_t > (uint8_t *ATH_RESTRICT &p, uint8_t val)
 
template<>
void CxxUtils::set_unaligned< uint16_t > (uint8_t *ATH_RESTRICT &p, uint16_t val)
 
template<>
void CxxUtils::set_unaligned< uint32_t > (uint8_t *ATH_RESTRICT &p, uint32_t val)
 
template<>
void CxxUtils::set_unaligned< uint64_t > (uint8_t *ATH_RESTRICT &p, uint64_t val)
 
template<>
void CxxUtils::set_unaligned< float > (uint8_t *ATH_RESTRICT &p, float f)
 
template<>
void CxxUtils::set_unaligned< double > (uint8_t *ATH_RESTRICT &p, double f)
 
template<>
void CxxUtils::set_unaligned< int8_t > (uint8_t *ATH_RESTRICT &p, int8_t val)
 
template<>
void CxxUtils::set_unaligned< int16_t > (uint8_t *ATH_RESTRICT &p, int16_t val)
 
template<>
void CxxUtils::set_unaligned< int32_t > (uint8_t *ATH_RESTRICT &p, int32_t val)
 
template<>
void CxxUtils::set_unaligned< int64_t > (uint8_t *ATH_RESTRICT &p, int64_t val)
 

Detailed Description

Write little-endian values through possibly unaligned pointers.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Jan, 2015 Doing, eg,
char* p = ...;
int* ip = reinterpret_cast<int*>(p);
*ip++ = i;

is undefined if p isn't aligned to an int boundary. It further will read the value using the host endianness, which is an issue for the common use case of reading persistent data.

The functions here allow writing little-endian data via possibly unaligned pointers regardless of the host byte ordering and without relying on undefined behavior.

Definition in file set_unaligned.h.

python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3