Skip to content

Commit

Permalink
Add trivial le_to_u8() endianness routine
Browse files Browse the repository at this point in the history
This is even more trivial than le_to_i8() but can be useful for the
regular treatment of unsigned types in #define BRANCH type switches.
  • Loading branch information
jmarshall committed Aug 12, 2022
1 parent 8d91938 commit 2a646be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions htslib/hts_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ typedef uint64_t uint64_u;
# endif
#endif

/// Get a uint8_t value from an unsigned byte array
/** @param buf Pointer to source byte, may be unaligned
* @return An 8-bit unsigned integer
*/
static inline uint8_t le_to_u8(const uint8_t *buf) {
return *buf;
}

/// Get a uint16_t value from an unsigned byte array
/** @param buf Pointer to source byte, may be unaligned
* @return A 16 bit unsigned integer
Expand Down

0 comments on commit 2a646be

Please sign in to comment.